123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- #include "hal_types.h"
- #include "OSAL.h"
- #include "hal_drivers.h"
- #include "hal_adc.h"
- #if (defined HAL_DMA) && (HAL_DMA == TRUE)
- #include "hal_dma.h"
- #endif
- #include "hal_key.h"
- #include "hal_lcd.h"
- #include "hal_led.h"
- #include "hal_timer.h"
- #include "hal_uart.h"
- #include "hal_sleep.h"
- #if (defined HAL_AES) && (HAL_AES == TRUE)
- #include "hal_aes.h"
- #endif
- #if (defined HAL_SPI) && (HAL_SPI == TRUE)
- #include "hal_spi.h"
- #endif
- #if (defined HAL_HID) && (HAL_HID == TRUE)
- #include "usb_hid.h"
- #endif
- #ifdef CC2591_COMPRESSION_WORKAROUND
- #include "mac_rx.h"
- #endif
- uint8 Hal_TaskID;
- extern void HalLedUpdate( void );
- void Hal_Init( uint8 task_id )
- {
-
- Hal_TaskID = task_id;
-
- #ifdef CC2591_COMPRESSION_WORKAROUND
- osal_start_reload_timer( Hal_TaskID, PERIOD_RSSI_RESET_EVT, PERIOD_RSSI_RESET_TIMEOUT );
- #endif
- }
- void HalDriverInit (void)
- {
-
- #if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
- #error "The hal timer driver module is removed."
- #endif
-
- #if (defined HAL_ADC) && (HAL_ADC == TRUE)
- HalAdcInit();
- #endif
-
- #if (defined HAL_DMA) && (HAL_DMA == TRUE)
-
- HalDmaInit();
- #endif
-
- #if (defined HAL_AES) && (HAL_AES == TRUE)
- HalAesInit();
- #endif
-
- #if (defined HAL_LCD) && (HAL_LCD == TRUE)
-
- #endif
-
- #if (defined HAL_LED) && (HAL_LED == TRUE)
-
- #endif
-
- #if (defined HAL_UART) && (HAL_UART == TRUE)
- HalUARTInit();
- #endif
-
- #if (defined HAL_KEY) && (HAL_KEY == TRUE)
-
- #endif
-
- #if (defined HAL_SPI) && (HAL_SPI == TRUE)
- HalSpiInit();
- #endif
-
- #if (defined HAL_HID) && (HAL_HID == TRUE)
- usbHidInit();
- #endif
- }
- uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
- {
- uint8 *msgPtr;
-
- (void)task_id;
- if ( events & SYS_EVENT_MSG )
- {
- msgPtr = osal_msg_receive(Hal_TaskID);
- while (msgPtr)
- {
-
-
- osal_msg_deallocate( msgPtr );
-
- msgPtr = osal_msg_receive( Hal_TaskID );
- }
- return events ^ SYS_EVENT_MSG;
- }
- if ( events & HAL_LED_BLINK_EVENT )
- {
- #if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
-
- #endif
- return events ^ HAL_LED_BLINK_EVENT;
- }
- if (events & HAL_KEY_EVENT)
- {
- #if (defined HAL_KEY) && (HAL_KEY == TRUE)
-
-
-
- #endif
- return events ^ HAL_KEY_EVENT;
- }
- #ifdef POWER_SAVING
- if ( events & HAL_SLEEP_TIMER_EVENT )
- {
- halRestoreSleepLevel();
- return events ^ HAL_SLEEP_TIMER_EVENT;
- }
- #endif
- #ifdef CC2591_COMPRESSION_WORKAROUND
- if ( events & PERIOD_RSSI_RESET_EVT )
- {
- macRxResetRssi();
- return (events ^ PERIOD_RSSI_RESET_EVT);
- }
- #endif
-
-
- return 0;
- }
- void Hal_ProcessPoll ()
- {
-
- #if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
- #error "The hal timer driver module is removed."
- #endif
-
- #if (defined HAL_UART) && (HAL_UART == TRUE)
- HalUARTPoll();
- #endif
-
- #if (defined HAL_SPI) && (HAL_SPI == TRUE)
- HalSpiPoll();
- #endif
-
- #if (defined HAL_HID) && (HAL_HID == TRUE)
- usbHidProcessEvents();
- #endif
-
- #if defined( POWER_SAVING )
-
- ALLOW_SLEEP_MODE();
- #endif
- }
|