/****************************************************************************** * @fn InitBoard() * @brief Initialize the CC22538DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { /* Interrupts off */ osal_int_disable( INTS_ALL ); HalKeyConfig( FALSE, NULL); //Config GPIO as input #if (defined OTA_CLIENT) && (OTA_CLIENT == TRUE) HalOTAInit(); #endif #ifdef HAL_UART_USB znpCfg1 = ZNP_CFG1_UART; znpCfg0 = ZNP_CFG0_32K_XTAL; #elif HAL_SPI znpCfg1 = ZNP_CFG1_SPI; znpCfg0 = ZNP_CFG0_32K_XTAL; #else znpCfg1 = ZNP_CFG1_UART; znpCfg0 = ZNP_CFG0_32K_XTAL; #endif } else /* !OB_COLD */ { /* Initialize Key stuff */ OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); } }
/********************************************************************* * @fn OnBoard_KeyCallback * * @brief Callback service for keys * * @param keys - keys that were pressed * state - shifted * * @return void *********************************************************************/ void OnBoard_KeyCallback ( uint8 keys, uint8 state ) { uint8 shift; (void)state; // shift key (S1) is used to generate key interrupt // applications should not use S1 when key interrupt is enabled shift = (OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE) ? false : ((keys & HAL_KEY_SW_6) ? true : false); if ( OnBoard_SendKeys( keys, shift ) != SUCCESS ) { // Process SW1 here if ( keys & HAL_KEY_SW_1 ) // Switch 1 { } // Process SW2 here if ( keys & HAL_KEY_SW_2 ) // Switch 2 { } // Process SW3 here if ( keys & HAL_KEY_SW_3 ) // Switch 3 { } // Process SW4 here if ( keys & HAL_KEY_SW_4 ) // Switch 4 { } // Process SW5 here if ( keys & HAL_KEY_SW_5 ) // Switch 5 { } // Process SW6 here if ( keys & HAL_KEY_SW_6 ) // Switch 6 { } } /* If any key is currently pressed down and interrupt is still enabled, disable interrupt and switch to polling */ if( keys != 0 ) { if( OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE ) { OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); } } /* If no key is currently pressed down and interrupt is disabled, enable interrupt and turn off polling */ else { if( OnboardKeyIntEnable == HAL_KEY_INTERRUPT_DISABLE ) { OnboardKeyIntEnable = HAL_KEY_INTERRUPT_ENABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); } } }
/********************************************************************* * @fn GenericApp_Init * * @brief Initialization function for the Generic App Task. * This is called during initialization and should contain * any application specific initialization (ie. hardware * initialization/setup, table initialization, power up * notificaiton ... ). * * @param task_id - the ID assigned by OSAL. This ID should be * used to send messages and set timers. * * @return none */ void uApp_Init( uint8 task_id ) { halUARTCfg_t uartConfig; uApp_TaskID = task_id; /* Setup keys */ HalKeyConfig(false, uApp_HandleKeys); /* Setup UART */ /* UART Configuration */ uartConfig.configured = TRUE; uartConfig.baudRate = HAL_UART_BR_38400; uartConfig.flowControl = 0; uartConfig.flowControlThreshold = 5; uartConfig.rx.maxBufSize = 128; uartConfig.tx.maxBufSize = 128; uartConfig.idleTimeout = 5; uartConfig.intEnable = TRUE; uartConfig.callBackFunc = uApp_UartProcessRxData; /* Start UART */ HalUARTOpen (0, &uartConfig); HalLcdWriteString("uApp started!", false); osal_start_timerEx(uApp_TaskID, UAPP_EVENT_1, 1000); //osal_set_event(uApp_TaskID, UAPP_EVENT_1); }
/********************************************************************* * @fn InitBoard() * @brief Initialize the CC2420DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { // IAR does not zero-out this byte below the XSTACK. *(uint8 *)0x0 = 0; // Interrupts off osal_int_disable( INTS_ALL ); // Check for Brown-Out reset ChkReset(); #if defined CC2531ZNP znpCfg1 = ZNP_CFG1_UART; #elif defined CC2530_MK znpCfg1 = ZNP_CFG1_SPI; znpCfg0 = ZNP_CFG0_32K_OSC; #else znpCfg1 = P2_0; znpCfg0 = P1_2; // Tri-state the 2 CFG inputs after being read (see hal_board_cfg_xxx.h for CFG0.) P1INP |= BV(2); P2INP |= BV(0); #endif } else // !OB_COLD { /* Initialize Key stuff */ HalKeyConfig(HAL_KEY_INTERRUPT_DISABLE, OnBoard_KeyCallback); } }
/************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize NV system */ osal_snv_init(); /* Initialize LL */ /* Initialize the operating system */ osal_init_system(); /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); /* Setup Keyboard callback */ HalKeyConfig(false, MSA_Main_KeyCallback); /* Blink LED on startup */ HalLedSet (HAL_LED_4, HAL_LED_MODE_ON); /* Start OSAL */ osal_start_system(); // No Return from here return 0; }
/************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize MAC */ MAC_Init(); /* Initialize the operating system */ osal_init_system(); /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); /* Setup OSAL Timer */ HalTimerConfig ( OSAL_TIMER, // 16bit timer3 HAL_TIMER_MODE_CTC, // Clear Timer on Compare HAL_TIMER_CHANNEL_SINGLE, // Channel 1 - default HAL_TIMER_CH_MODE_OUTPUT_COMPARE, // Output Compare mode FALSE, // Use interrupt MSA_Main_TimerCallBack); // Channel Mode /* Setup Keyboard callback */ HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback); /* Initialize UART */ UartCnfg.baudRate = HAL_UART_BR_9600; UartCnfg.callBackFunc = HalUARTCBack; UartCnfg.flowControl = FALSE; UartCnfg.flowControlThreshold = 0; /* max Buffer Size in Byte*/ UartCnfg.idleTimeout = 200; /* * halUARTOpen provvederà tramite la funzione halUartAllocBuffers ad allocare e inizializzare * le strutture dati RxUART e TxUART. */ UartCnfg.rx = RxUART; UartCnfg.tx = TxUART; UartCnfg.rx.maxBufSize = UART_MAX_BUFFER_SIZE; UartCnfg.tx.maxBufSize = UART_MAX_BUFFER_SIZE; UartCnfg.intEnable = TRUE ; /* enable or disable the interrupts */ UartCnfg.configured = TRUE; uint8 status = HalUARTOpen(HAL_UART_PORT, &UartCnfg); /* passo l'indirizzo di memoria della struttura dati UartCnfg, Passaggio per riferimento!!!*/ /* Start OSAL */ osal_start_system(); // No Return from here return 0; }
/****************************************************************************** * @fn InitBoard() * @brief Initialize the CC22538DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { // Interrupts off osal_int_disable( INTS_ALL ); HalKeyConfig( FALSE, NULL); //Config GPIO as input #if (defined OTA_CLIENT) && (OTA_CLIENT == TRUE) HalOTAInit(); #endif } else // !OB_COLD { /* Initialize Key stuff */ OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); } }
/********************************************************************* * @fn InitBoard * * @brief Initialize CC26xx board and HAL. * * @param None * * @return None * *********************************************************************/ void InitBoard() { // Enable or Disable HAL Key Interrupts. OnboardKeyIntEnable = HAL_KEY_MODE; // Configure HAL Keys #if (defined HAL_KEY) && (HAL_KEY == TRUE) HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); #endif // (defined HAL_KEY) && (HAL_KEY == TRUE) }
/********************************************************************* * @fn InitBoard() * @brief Initialize the CC2420DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { // IAR does not zero-out this byte below the XSTACK. *(uint8 *)0x0 = 0; // Interrupts off osal_int_disable( INTS_ALL ); // Check for Brown-Out reset ChkReset(); } else // !OB_COLD { /* Initialize Key stuff */ #if defined (ISR_KEYINTERRUPT) HalKeyConfig(HAL_KEY_INTERRUPT_ENABLE , OnBoard_KeyCallback); #else HalKeyConfig(HAL_KEY_INTERRUPT_DISABLE, OnBoard_KeyCallback); #endif } }
/********************************************************************* * @fn InitBoard() * @brief Initialize the CC2420DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { // Interrupts off osal_int_disable( INTS_ALL ); } else // !OB_COLD { /* Initialize Key stuff */ HalKeyConfig(HAL_KEY_INTERRUPT_DISABLE, OnBoard_KeyCallback); } }
/********************************************************************* * @fn InitBoard() * @brief Initialize the CC2540DB Board Peripherals * @param level: COLD,WARM,READY * @return None */ void InitBoard( uint8 level ) { if ( level == OB_COLD ) { // Interrupts off osal_int_disable( INTS_ALL ); // Turn all LEDs off HalLedSet( HAL_LED_ALL, HAL_LED_MODE_OFF ); // Check for Brown-Out reset // ChkReset(); } else // !OB_COLD { /* Initialize Key stuff */ OnboardKeyIntEnable = HAL_KEY_INTERRUPT_ENABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); } }
/************************************************************************************************** * @fn main * * @brief Start of application. * * @param none * * @return none ************************************************************************************************** */ int main(void) { /* Initialize hardware */ HAL_BOARD_INIT(); /* Initialze the HAL driver */ HalDriverInit(); /* Initialize MAC */ MAC_Init(); /* Initialize the operating system */ osal_init_system(); #ifdef HAL_BOARD_CC2538 /* Master enable interrupts */ IntMasterEnable(); /* Setup SysTick to generate interrupt every 1 ms */ SysTickSetup(); #endif /* HAL_BOARD_CC2538 */ /* Enable interrupts */ HAL_ENABLE_INTERRUPTS(); /* Setup Keyboard callback */ HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback); /* Blink LED on startup */ HalLedBlink (HAL_LED_4, 0, 40, 200); /* Start OSAL */ OSAL_START_SYSTEM(); return 0; }
/********************************************************************* * @fn InitBoard() * @brief Initialize the CC2420DB Board Peripherals * @param None * @return None */ void InitBoard(void) { OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE; HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback); }