void main(void) { uint16 crc[2]; HAL_BOARD_INIT(); #if HAL_OAD_XNV_IS_SPI XNV_SPI_INIT(); #endif /* This is in place of calling HalDmaInit() which would require init of the other 4 DMA * descriptors in addition to just Channel 0. */ HAL_DMA_SET_ADDR_DESC0( &dmaCh0 ); HalFlashInit(); HalFlashRead(HAL_OAD_CRC_ADDR / HAL_FLASH_PAGE_SIZE, HAL_OAD_CRC_ADDR % HAL_FLASH_PAGE_SIZE, (uint8 *)crc, sizeof(crc)); if (crc[0] != crc[1]) { // If the CRC is erased or the RC code fails a sanity check, instantiate the DL code (again). if ((crc[0] == 0) || (crc[0] != crcCalc())) { dl2rc(); /* If dl2rc() fails, a flawed image is allowed to run - * maybe the damage is not fatal to OTA ops? */ } else { crc[1] = crc[0]; HalFlashWrite((HAL_OAD_CRC_ADDR / HAL_FLASH_WORD_SIZE), (uint8 *)crc, 1); } } // Simulate a reset for the Application code by an absolute jump to location 0x0800. asm("LJMP 0x800\n"); }
/************************************************************************************************** * @fn Hal_DriverInit (ªì©l¤ÆµwÅ骺ÅX°Êµ{§Ç, ¨Ï¥ÎªÌ¥i¦b¦¹¨ç¼Æ²K¥[¬ÛÃöµwÅé) * * @brief Initialize HW - These need to be initialized before anyone. * * @param task_id - Hal TaskId * * @return None **************************************************************************************************/ void HalDriverInit (void) { /* TIMER */ #if (defined HAL_TIMER) && (HAL_TIMER == TRUE) HalTimerInit(); #endif /* ADC */ #if (defined HAL_ADC) && (HAL_ADC == TRUE) HalAdcInit(); #if defined(M170) M170_Init(); #endif #endif /* DMA */ #if (defined HAL_DMA) && (HAL_DMA == TRUE) // Must be called before the init call to any module that uses DMA. HalDmaInit(); #endif /* Flash */ #if (defined HAL_FLASH) && (HAL_FLASH == TRUE) // Must be called before the init call to any module that uses Flash access or NV. HalFlashInit(); #endif /* AES */ #if (defined HAL_AES) && (HAL_AES == TRUE) HalAesInit(); #endif /* LCD */ #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdInit(); #endif /* UART */ #if (defined HAL_UART) && (HAL_UART == TRUE) HalUARTInit(); #endif /* KEY */ #if (defined HAL_KEY) && (HAL_KEY == TRUE) HalKeyInit(); #endif /* SPI */ #if (defined HAL_SPI) && (HAL_SPI == TRUE) HalSpiInit(); #endif /* HID */ #if (defined HAL_HID) && (HAL_HID == TRUE) usbHidInit(); #endif /* KEYPAD */ #if (defined HAL_KEYPAD) && (HAL_KEYPAD == TRUE) halKeypadInit(); #endif /* BUZZER */ #if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE) halBuzzerInit(); #endif /* I2C (M200 module) */ #if (defined HAL_I2C) && (HAL_I2C == TRUE) #if defined(M200) M200_Init(); #endif #endif /* LED */ #if (defined HAL_LED) && (HAL_LED == TRUE) HalLedInit(); #endif }