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 )
100 PAL_SPI_USART_UNIT->ROUTEPEN = USART_ROUTEPEN_TXPEN
101 | USART_ROUTEPEN_CLKPEN;
102 PAL_SPI_USART_UNIT->ROUTELOC0 = ( PAL_SPI_USART_UNIT->ROUTELOC0 &
103 ~( _USART_ROUTELOC0_TXLOC_MASK | _USART_ROUTELOC0_CLKLOC_MASK ) )
104 | ( PAL_SPI_USART_LOCATION_TX << _USART_ROUTELOC0_TXLOC_SHIFT )
105 | ( PAL_SPI_USART_LOCATION_SCLK << _USART_ROUTELOC0_CLKLOC_SHIFT );
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)
439 uint32_t source = PRS_CH_CTRL_SOURCESEL_RTCC;
440 uint32_t signal = PRS_CH_CTRL_SIGSEL_RTCCCCV1;
450 PRS_SourceAsyncSignalSet(LCD_AUTO_TOGGLE_PRS_CH, source, signal);
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)
500 #if defined(PAL_CLOCK_RTCC)
506 void RTCC_IRQHandler(
void)
509 RTCC_IntClear(RTCC_IF_CC1);
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)
581 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
593 #if defined(PAL_CLOCK_RTCC)
598 static void rtccSetup(
unsigned int frequency)
600 RTCC_Init_TypeDef rtccInit = RTCC_INIT_DEFAULT;
601 rtccInit.presc = rtccCntPresc_1;
603 palClockSetup(cmuClock_LFE);
608 rtccInit.enable =
false;
609 rtccInit.debugRun =
false;
610 rtccInit.cntWrapOnCCV1 =
true;
611 RTCC_Init(&rtccInit);
614 RTCC_CCChConf_TypeDef ccchConf = RTCC_CH_INIT_COMPARE_DEFAULT;
615 ccchConf.compMatchOutAction = rtccCompMatchOutActionToggle;
616 RTCC_ChannelInit(1, &ccchConf);
619 #ifndef INCLUDE_PAL_GPIO_PIN_AUTO_TOGGLE_HW_ONLY
621 NVIC_EnableIRQ(RTCC_IRQn);
622 RTCC_IntEnable(RTCC_IEN_CC1);
625 RTCC->CNT = _RTCC_CNT_RESETVALUE;
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.
__STATIC_INLINE void GPIO_PinOutToggle(GPIO_Port_TypeDef port, unsigned int pin)
Toggle a single pin in GPIO port data out register.
void RTC_CounterReset(void)
Restart RTC counter from zero.
__STATIC_INLINE void RTC_IntClear(uint32_t flags)
Clear one or more pending RTC interrupts.
#define PRS_CH_CTRL_SIGSEL_RTCCOMP0
void UDELAY_Calibrate(void)
Calibrates the microsecond delay loop.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define USART_ROUTE_CLKPEN
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
void RTC_CompareSet(unsigned int comp, uint32_t value)
Set RTC compare register value.
Platform Abstraction Layer (PAL) interface for DISPLAY driver.
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
#define CMU_STATUS_LFXOENS
General Purpose IO (GPIO) peripheral API.
Microsecond delay routine.
Real Time Counter (RTCC) peripheral API.
__STATIC_INLINE void RTC_IntEnable(uint32_t flags)
Enable one or more RTC interrupts.
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
void RTC_Init(const RTC_Init_TypeDef *init)
Initialize RTC.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
Real Time Counter (RTC) peripheral API.
void CMU_OscillatorEnable(CMU_Osc_TypeDef osc, bool enable, bool wait)
Enable/disable oscillator.
Main configuration file for the DISPLAY driver software stack.
void RTC_Enable(bool enable)
Enable/disable RTC.
#define PRS_CH_CTRL_SOURCESEL_RTC
__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_ROUTE_TXPEN
#define USART_INITSYNC_DEFAULT
uint32_t CMU_ClockFreqGet(CMU_Clock_TypeDef clock)
Get clock frequency for a clock point.
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.