35 #ifdef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE
37 #if defined(RTCC_PRESENT) && (RTCC_COUNT > 0) && !defined(PAL_CLOCK_RTC)
38 #define PAL_CLOCK_RTCC
45 #ifdef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
57 #ifdef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE
58 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
60 static unsigned int gpioPortNo;
61 static unsigned int gpioPinNo;
66 #if defined(PAL_CLOCK_RTCC)
67 static void rtccSetup(
unsigned int frequency);
69 static void rtcSetup(
unsigned int frequency);
87 EMSTATUS PAL_SpiInit (
void)
94 usartInit.
baudrate = PAL_SPI_BAUDRATE;
98 #if defined( USART_ROUTEPEN_TXPEN )
102 PAL_SPI_USART_UNIT->ROUTELOC0 = ( PAL_SPI_USART_UNIT->ROUTELOC0 &
109 PAL_SPI_USART_UNIT->ROUTE = (USART_ROUTE_CLKPEN | USART_ROUTE_TXPEN | PAL_SPI_USART_LOCATION);
125 EMSTATUS PAL_SpiShutdown (
void)
147 EMSTATUS PAL_SpiTransmit (uint8_t* data,
unsigned int len)
155 if ((len == 1) || ((
unsigned int)data & 0x1))
157 USART_Tx( PAL_SPI_USART_UNIT, *(uint8_t*)data );
184 EMSTATUS PAL_TimerInit (
void)
202 EMSTATUS PAL_TimerShutdown (
void)
221 EMSTATUS PAL_TimerMicroSecondsDelay(
unsigned int usecs)
231 #ifdef PAL_TIMER_REPEAT_FUNCTION
242 EMSTATUS PAL_TimerRepeat (
void(*pFunction)(
void*),
244 unsigned int frequency)
246 if (0 != PAL_TIMER_REPEAT_FUNCTION(pFunction, argument, frequency))
262 EMSTATUS PAL_GpioInit (
void)
281 EMSTATUS PAL_GpioShutdown (
void)
313 EMSTATUS PAL_GpioPinModeSet(
unsigned int port,
316 unsigned int platformSpecific)
324 case palGpioModePushPull:
354 EMSTATUS PAL_GpioPinOutSet(
unsigned int port,
unsigned int pin)
381 EMSTATUS PAL_GpioPinOutClear(
unsigned int port,
unsigned int pin)
408 EMSTATUS PAL_GpioPinOutToggle(
unsigned int port,
unsigned int pin)
418 #ifdef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE
427 EMSTATUS PAL_GpioPinAutoToggle (
unsigned int gpioPort,
428 unsigned int gpioPin,
429 unsigned int frequency)
433 #ifdef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
438 #if defined(PAL_CLOCK_RTCC)
442 uint32_t source = PRS_CH_CTRL_SOURCESEL_RTC;
443 uint32_t signal = PRS_CH_CTRL_SIGSEL_RTCCOMP0;
453 #if defined(_SILICON_LABS_32B_PLATFORM_2)
454 LCD_AUTO_TOGGLE_PRS_ROUTELOC();
455 PRS->ROUTEPEN |= LCD_AUTO_TOGGLE_PRS_ROUTEPEN;
457 PRS->ROUTE = (
PRS->ROUTE & ~_PRS_ROUTE_LOCATION_MASK )
458 | LCD_AUTO_TOGGLE_PRS_ROUTE_LOC;
459 PRS->ROUTE |= LCD_AUTO_TOGGLE_PRS_ROUTE_PEN;
464 gpioPortNo = gpioPort;
471 #if defined(PAL_CLOCK_RTCC)
473 rtccSetup(frequency);
483 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
484 #if defined(PAL_CLOCK_RTC)
490 void RTC_IRQHandler(
void)
493 RTC_IntClear(RTC_IF_COMP0);
500 #if defined(PAL_CLOCK_RTCC)
506 void RTCC_IRQHandler(
void)
528 #if ( defined(PAL_CLOCK_RTC) && defined(PAL_RTC_CLOCK_LFXO) ) \
529 || ( defined(PAL_CLOCK_RTCC) && defined(PAL_RTCC_CLOCK_LFXO) )
540 #elif ( defined(PAL_CLOCK_RTC) && defined(PAL_RTC_CLOCK_LFRCO) ) \
541 || ( defined(PAL_CLOCK_RTCC) && defined(PAL_RTCC_CLOCK_LFRCO) )
544 #elif ( defined(PAL_CLOCK_RTC) && defined(PAL_RTC_CLOCK_ULFRCO) ) \
545 || ( defined(PAL_CLOCK_RTCC) && defined(PAL_RTCC_CLOCK_ULFRCO) )
549 #error No clock source for RTC defined.
554 #if defined(PAL_CLOCK_RTC)
559 static void rtcSetup(
unsigned int frequency)
561 RTC_Init_TypeDef rtcInit = RTC_INIT_DEFAULT;
572 rtcInit.enable =
false;
573 rtcInit.debugRun =
false;
574 rtcInit.comp0Top =
true;
579 RTC_CompareSet(0, ((
CMU_ClockFreqGet(cmuClock_RTC) / frequency) - 1) & _RTC_COMP0_MASK );
581 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
583 NVIC_EnableIRQ(RTC_IRQn);
584 RTC_IntEnable(RTC_IEN_COMP0);
593 #if defined(PAL_CLOCK_RTCC)
598 static void rtccSetup(
unsigned int frequency)
619 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
Clock management unit (CMU) API.
void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref)
Select reference clock/oscillator used for a clock branch.
void USART_Tx(USART_TypeDef *usart, uint8_t data)
Transmit one 4-9 bit frame.
#define PAL_EMSTATUS_INVALID_PARAM
Board support package API definitions.
void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
Init USART for synchronous mode.
void RTCC_Init(const RTCC_Init_TypeDef *init)
Initialize RTCC.
void RTCC_Enable(bool enable)
Enable/disable RTCC.
__STATIC_INLINE void GPIO_PinOutToggle(GPIO_Port_TypeDef port, unsigned int pin)
Toggle a single pin in GPIO port data out register.
#define _USART_ROUTELOC0_TXLOC_SHIFT
#define PRS_CH_CTRL_SOURCESEL_RTCC
void UDELAY_Calibrate(void)
Calibrates the microsecond delay loop.
#define USART_ROUTEPEN_TXPEN
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
__STATIC_INLINE void RTCC_ChannelCCVSet(int ch, uint32_t value)
Set RTCC capture/compare register value (CCV) for selected channel.
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
#define RTCC_INIT_DEFAULT
RTCC_CompMatchOutAction_TypeDef compMatchOutAction
RTCC_CntPresc_TypeDef presc
#define CMU_STATUS_LFXOENS
Platform Abstraction Layer (PAL) interface for DISPLAY driver.
__STATIC_INLINE void RTCC_IntClear(uint32_t flags)
Clear one or more pending RTCC interrupts.
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
void RTCC_ChannelInit(int ch, RTCC_CCChConf_TypeDef const *confPtr)
Configure the selected capture/compare channel of the RTCC.
#define PRS_CH_CTRL_SIGSEL_RTCCCCV1
General Purpose IO (GPIO) peripheral API.
Microsecond delay routine.
Real Time Counter (RTCC) peripheral API.
#define _USART_ROUTELOC0_TXLOC_MASK
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define _USART_ROUTELOC0_CLKLOC_MASK
Real Time Counter (RTC) peripheral API.
#define RTCC_CH_INIT_COMPARE_DEFAULT
void CMU_OscillatorEnable(CMU_Osc_TypeDef osc, bool enable, bool wait)
Enable/disable oscillator.
Main configuration file for the DISPLAY driver software stack.
#define _USART_ROUTELOC0_CLKLOC_SHIFT
#define _RTCC_CNT_RESETVALUE
#define USART_ROUTEPEN_CLKPEN
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out port register to 0.
void USART_Enable(USART_TypeDef *usart, USART_Enable_TypeDef enable)
Enable/disable USART/UART receiver and/or transmitter.
#define USART_INITSYNC_DEFAULT
__STATIC_INLINE void RTCC_IntEnable(uint32_t flags)
Enable one or more RTCC interrupts.
uint32_t CMU_ClockFreqGet(CMU_Clock_TypeDef clock)
Get clock frequency for a clock point.
void PRS_SourceAsyncSignalSet(unsigned int ch, uint32_t source, uint32_t signal)
Set source and asynchronous signal to be used for a channel.
Peripheral Reflex System (PRS) peripheral API.
void CMU_ClockDivSet(CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div)
Set clock divisor/prescaler.
void USART_TxDouble(USART_TypeDef *usart, uint16_t data)
Transmit two 4-9 bit frames, or one 10-16 bit frame.
void UDELAY_Delay(uint32_t usecs)
Microsecond active wait delay routine.
#define PAL_EMSTATUS_REPEAT_FAILED
CMU_Select_TypeDef CMU_ClockSelectGet(CMU_Clock_TypeDef clock)
Get currently selected reference clock used for a clock branch.