blob: 6944b6901218bf3d021d64c0925f2627f8a760e0 [file] [log] [blame]
/******************************************************************************
* @file main.c
*
* @brief for TLSR chips
*
* @author public@telink-semi.com;
* @date Sep. 30, 2010
*
* @attention
*
* Copyright (C) 2019-2020 Telink Semiconductor (Shanghai) Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#include "tl_common.h"
#include "drivers.h"
#include "stack/ble/ble.h"
#include "vendor/common/blt_common.h"
extern my_fifo_t hci_rx_fifo;
extern void user_init();
extern void main_loop (void);
extern void app_i2c_test_irq_proc(void);
extern void app_uart_test_irq_proc(void);
extern void app_spi_test_irq_proc(void);
extern void app_timer_test_irq_proc(void);
extern void app_gpio_irq_test_proc(void);
extern void app_pwm_irq_test_proc(void);
_attribute_ram_code_ void irq_handler(void)
{
/***timer demo***/
#if (DRIVER_TEST_MODE == TEST_HW_TIMER)
app_timer_test_irq_proc();
/***uart demo***/
#elif (DRIVER_TEST_MODE == TEST_UART)
app_uart_test_irq_proc();
/***i2c demo***/
#elif (DRIVER_TEST_MODE == TEST_IIC)
app_i2c_test_irq_proc();
/***spi demo ***/
#elif (DRIVER_TEST_MODE == TEST_SPI)
app_spi_test_irq_proc();
#elif (DRIVER_TEST_MODE == TEST_GPIO_IRQ)
app_gpio_irq_test_proc();
#elif (DRIVER_TEST_MODE == TEST_PWM)
app_pwm_irq_test_proc();
#endif
}
int main (void) {
blc_pm_select_internal_32k_crystal();
#if(MCU_CORE_TYPE == MCU_CORE_8258)
cpu_wakeup_init();
#elif(MCU_CORE_TYPE == MCU_CORE_8278)
cpu_wakeup_init(LDO_MODE,EXTERNAL_XTAL_24M);
#endif
int deepRetWakeUp = pm_is_MCU_deepRetentionWakeup(); //MCU deep retention wakeUp
rf_drv_init(RF_MODE_BLE_1M);
gpio_init(!deepRetWakeUp);
#if (CLOCK_SYS_CLOCK_HZ == 16000000)
clock_init(SYS_CLK_16M_Crystal);
#elif (CLOCK_SYS_CLOCK_HZ == 24000000)
clock_init(SYS_CLK_24M_Crystal);
#endif
if(!deepRetWakeUp){//read flash size
blc_readFlashSize_autoConfigCustomFlashSector();
}
blc_app_loadCustomizedParameters();
if(!deepRetWakeUp){
random_generator_init();
}
user_init();
while (1) {
#if (MODULE_WATCHDOG_ENABLE)
wd_clear(); //clear watch dog
#endif
main_loop ();
}
}