Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions FreeRTOS/include/task.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,11 @@ void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUN
*/
signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pvTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION;

/*
* Checks if blocked tasks exist that require the RTOS tick
*/
signed portBASE_TYPE xTaskTickRequired( void ) PRIVILEGED_FUNCTION;

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/portable/MSP430F5438/FreeRTOSConfig.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ occurs.
#ifdef ANALOG
#define configTOTAL_HEAP_SIZE ((size_t)12044)
#else
#define configTOTAL_HEAP_SIZE ((size_t)12340) //12364 12492 12486, 12526, 12424, 12290, 12334, 12000, 12328, 13500
#define configTOTAL_HEAP_SIZE ((size_t)12320) //12340 12364 12492 12486, 12526, 12424, 12290, 12334, 12000, 12328, 13500
#endif

#define configMAX_TASK_NAME_LEN (16)
Expand Down
32 changes: 22 additions & 10 deletions FreeRTOS/portable/MSP430F5438/portmacro.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,28 @@ typedef char tString;
/* Critical section control macros. */
#define portNO_CRITICAL_SECTION_NESTING ( ( unsigned portSHORT ) 0 )

#define portENTER_CRITICAL() \
{ \
extern volatile unsigned portSHORT usCriticalNesting; \
__disable_interrupt(); \
__no_operation(); \
\
/* Now interrupts are disabled usCriticalNesting can be accessed */ \
/* directly. Increment ulCriticalNesting to keep a count of how many */ \
/* times portENTER_CRITICAL() has been called. */ \
usCriticalNesting++; \
#define portENTER_CRITICAL() \
{ \
extern volatile unsigned portSHORT usCriticalNesting; \
\
/* If this is the first call and the interrupts are disabled, \
* the code is called from an ISR. In this case do not enter \
* a critical section. Otherwise, interrupts can get enabled if \
* portEXT_CRITICAL is called. This would enable interrupts while \
* the ISR is active. But FreeRTOS requires that some of its \
* "fromISR" functions are called with interrupts disabled. \
*/ \
if (( usCriticalNesting != portNO_CRITICAL_SECTION_NESTING ) || \
((__get_interrupt_state() & GIE))) { \
\
__disable_interrupt(); \
__no_operation(); \
\
/* Now interrupts are disabled usCriticalNesting can be accessed */ \
/* directly. Increment ulCriticalNesting to keep a count of how many */ \
/* times portENTER_CRITICAL() has been called. */ \
usCriticalNesting++; \
} \
}

#define portEXIT_CRITICAL() \
Expand Down
9 changes: 9 additions & 0 deletions FreeRTOS/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,15 @@ void vTaskExitCritical( void )
#endif
/*-----------------------------------------------------------*/

signed portBASE_TYPE xTaskTickRequired( void )
{
if( !listLIST_IS_EMPTY( pxDelayedTaskList ) )
return pdTRUE;
if( !listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) )
return pdTRUE;
return pdFALSE;
}

/*-----------------------------------------------------------*/


8 changes: 7 additions & 1 deletion Watch/Application/Accelerometer.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ void HandleAccelerometer(tMessage *pMsg)

case MSG_OPT_ACCEL_DISABLE:
DisableAccelerometer();
CreateAndSendMessage(UpdConnParamMsg, LongInterval);

if (Connected(CONN_TYPE_BLE))
CreateAndSendMessage(UpdConnParamMsg, LongInterval);

else if (Connected(CONN_TYPE_SPP))
CreateAndSendMessage(SniffControlMsg, MSG_OPT_ENTER_SNIFF);

break;

case MSG_OPT_ACCEL_STREAMING:
Expand Down
2 changes: 1 addition & 1 deletion Watch/Application/Adc.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void InitAdc(void)
ADC12MCTL2 = LIGHT_SENSE_INPUT_CHANNEL + ADC12EOS;

/* init to 0 */
memset(Sample, 0, MAX_SAMPLES << 2);
memset(Sample, 0, MAX_SAMPLES << 1);

/* control access to adc peripheral */
AdcMutex = xSemaphoreCreateMutex();
Expand Down
10 changes: 8 additions & 2 deletions Watch/Application/Buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typedef struct

#ifdef DIGITAL

#define CONN_PAGE_ACT_NUM (20) // 3rd party needs 16
#define CONN_PAGE_ACT_NUM (32) // 3rd party needs 16

static const tButtonAction DisconnAction[] =
{
Expand Down Expand Up @@ -367,7 +367,9 @@ static void HandleButtonEvent(unsigned char Index, unsigned char Event)
{
tMessage Msg;

// PrintS(tringAndTwoDecimals("- BtnEvt i:", Index, "e:", Event);
//PrintF("Index=%d Event=%d",Index,Event);

// PrintS(tringAndTwoDecimals("- BtnEvt i:", Index, "e:", Event);
// PrintS(tringAndHexByte("LstBF:0x", LastButton);

unsigned char Done = pdFALSE;
Expand Down Expand Up @@ -476,6 +478,7 @@ static void HandleButtonEvent(unsigned char Index, unsigned char Event)
Msg.pBuffer[2] = Event;
Msg.pBuffer[3] = pAction[i].MsgType;
Msg.pBuffer[4] = pAction[i].MsgOpt;
//PrintF("Contents: ButtonIndex=%d ButtonMode=%d Event=%d MsgType=%d MsgOpt=%d",Msg.pBuffer[0],Msg.pBuffer[1],Msg.pBuffer[2],Msg.pBuffer[3],Msg.pBuffer[4]);
Msg.Length = 5;
RouteMsg(&Msg);
}
Expand Down Expand Up @@ -509,6 +512,8 @@ void EnableButtonMsgHandler(tMessage* pMsg)
pAction->ButtonIndex << BTN_NO_SHFT |
pAction->ButtonEvent;

//PrintF("DisplayMode=%d ButtonIndex=%d ButtonEvent=%d",pAction->DisplayMode,pAction->ButtonIndex,pAction->ButtonEvent);

unsigned char i, k = CONN_PAGE_ACT_NUM;

for (i = 0; i < CONN_PAGE_ACT_NUM; ++i)
Expand All @@ -524,6 +529,7 @@ void EnableButtonMsgHandler(tMessage* pMsg)
ButtonAction[i].Info = BtnInfo;
ButtonAction[i].MsgType = pAction->CallbackMsgType;
ButtonAction[i].MsgOpt = pAction->CallbackMsgOptions;
//PrintF("i=%d MsgType=%d MsgOpt=%d",i,pAction->CallbackMsgType,pAction->CallbackMsgOptions);
}
else PrintS("# DefBtn");
}
Expand Down
8 changes: 8 additions & 0 deletions Watch/Application/LcdDisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void Init(void)

InitBattery();
CheckClip();
__enable_interrupt();

PrintF("*** %s:%s ***", niReset == FLASH_RESET_CODE ? "FLASH" :
(niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild);
Expand Down Expand Up @@ -365,6 +366,13 @@ static void DisplayQueueMessageHandler(tMessage* pMsg)
UpdateClock();
break;

case GetRtcMsg:
SetupMessageWithBuffer(&Msg, RtcRespMsg, MSG_OPT_NONE);
GetRtc((Rtc_t*)Msg.pBuffer);
Msg.Length = sizeof(Rtc_t);
RouteMsg(&Msg);
break;

#if COUNTDOWN_TIMER
case CountDownMsg:
if (pMsg->Options == MSG_OPT_NONE)
Expand Down
3 changes: 2 additions & 1 deletion Watch/Hardware/hal_lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void EnterLpm3(void)
* we are already in critical section so that we do not get switched out by the
* OS in the middle of stopping the OS Scheduler.
*/
DisableRtosTick();
if (!xTaskTickRequired())
DisableRtosTick();

/* errata PMM11 + PMM12 divide MCLK by two before going to sleep */
if (Errata()) MCLK_DIV(2);
Expand Down
14 changes: 14 additions & 0 deletions Watch/Hardware/hal_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ void SetRtc(Rtc_t *pRtcData)
EnableTimeStamp();
}

void GetRtc(Rtc_t* pRtcData)
{
tWordByteUnion temp;
temp.word = RTCYEAR;
pRtcData->YearLsb = temp.Bytes.byte0;
pRtcData->YearMsb = temp.Bytes.byte1;
pRtcData->Month = RTCMON;
pRtcData->Day = RTCDAY;
pRtcData->DayOfWeek = RTCDOW;
pRtcData->Hour = RTCHOUR;
pRtcData->Minute = RTCMIN;
pRtcData->Second = RTCSEC;
}

static void RestoreRtc(void)
{
CheckResetCode();
Expand Down
7 changes: 7 additions & 0 deletions Watch/Hardware/hal_rtc.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ void InitRealTimeClock(void);
*/
void SetRtc(Rtc_t *pRtcData);

/*! Get the current structure containing the real time clock parameters.
*
* \param pRtcData
*
*/
void GetRtc(Rtc_t* pRtcData);

void BackupRtc(void);

void IncRtc(unsigned char Index);
Expand Down
2 changes: 2 additions & 0 deletions Watch/Hardware/hal_rtos_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ void SetupRtosTimer(void)
*/
void EnableRtosTick(void)
{
if (RtosTickEnabled) return;
RtosTickEnabled = 1;
AddUser(TIMER0_RTOS_USER,RTOS_TICK_COUNT);
}

void DisableRtosTick(void)
{
if (!RtosTickEnabled) return;
RtosTickEnabled = 0;
RemoveUser(TIMER0_RTOS_USER);
}
Expand Down
Loading