⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intnest.c

📁 ecos移植到R8H系列的源码。源码包来自http://www.cetoni.de/develop/develop_ecosh8s_en.html
💻 C
📖 第 1 页 / 共 2 页
字号:
void thread_tmr_entry(cyg_addrword_t data){    //    // initialise and seven hardware timers with seven different     // interrupt priorities    //    tpu0_setup();    tpu1_setup();    tpu2_setup();    tpu3_setup();    tpu4_setup();    tmr0_setup();    tmr1_setup();        //    // now start the first lowest priority interrupt timer    //    cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_TCI0V);        while (1)    {        // do nothing    }   }//===========================================================================//                                TPU0 SETUP//===========================================================================void tpu0_setup(void){     cyg_uint8 tmp;        //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_TCR0, CYGARC_TCR_TPSC_1);           //    // create tpu0 interrupt    //    int_tpu0.prio = CYGNUM_HAL_INT_PRIO_1;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TCI0V,                         int_tpu0.prio,                         (cyg_addrword_t)&int_tpu0.prio,                         tpu0_ISR,                         0,                         &int_tpu0.hdl,                         &int_tpu0.obj                         );                             cyg_interrupt_attach(int_tpu0.hdl);    //    // Now start the counter 0    //    HAL_READ_UINT8(CYGARC_TSTR, tmp);    tmp |= CYGARC_TSTR_CST0;    HAL_WRITE_UINT8(CYGARC_TSTR, tmp); }//===========================================================================//                                TPU1 SETUP//===========================================================================void tpu1_setup(void){       cyg_uint8 tmp;    //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_TCR1, CYGARC_TCR_TPSC_1);          //    // create tpu0 interrupt    //    int_tpu1.prio = CYGNUM_HAL_INT_PRIO_2;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TCI1V,                         int_tpu1.prio,                         (cyg_addrword_t)&int_tpu1.prio,                         tpu1_ISR,                         0,                         &int_tpu1.hdl,                         &int_tpu1.obj                         );                             cyg_interrupt_attach(int_tpu1.hdl);        HAL_READ_UINT8(CYGARC_TSTR, tmp);    tmp |= CYGARC_TSTR_CST1;    HAL_WRITE_UINT8(CYGARC_TSTR, tmp);}//===========================================================================//                                TPU2 SETUP//===========================================================================void tpu2_setup(void){       cyg_uint8 tmp;    //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_TCR2, CYGARC_TCR_TPSC_1);          //    // create tpu0 interrupt    //    int_tpu2.prio = CYGNUM_HAL_INT_PRIO_3;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TCI2V,                         int_tpu2.prio,                         (cyg_addrword_t)&int_tpu2.prio,                         tpu2_ISR,                         0,                         &int_tpu2.hdl,                         &int_tpu2.obj                         );                             cyg_interrupt_attach(int_tpu2.hdl);        HAL_READ_UINT8(CYGARC_TSTR, tmp);    tmp |= CYGARC_TSTR_CST2;    HAL_WRITE_UINT8(CYGARC_TSTR, tmp);}//===========================================================================//                                TPU3 SETUP//===========================================================================void tpu3_setup(void){       cyg_uint8 tmp;    //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_TCR3, CYGARC_TCR_TPSC_1);          //    // create tpu0 interrupt    //    int_tpu3.prio = CYGNUM_HAL_INT_PRIO_4;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TCI3V,                         int_tpu3.prio,                         (cyg_addrword_t)&int_tpu3.prio,                         tpu3_ISR,                         0,                         &int_tpu3.hdl,                         &int_tpu3.obj                         );                             cyg_interrupt_attach(int_tpu3.hdl);        HAL_READ_UINT8(CYGARC_TSTR, tmp);    tmp |= CYGARC_TSTR_CST3;    HAL_WRITE_UINT8(CYGARC_TSTR, tmp);}//===========================================================================//                                TPU4 SETUP//===========================================================================void tpu4_setup(void){       cyg_uint8 tmp;    //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_TCR4, CYGARC_TCR_TPSC_1);          //    // create tpu0 interrupt    //    int_tpu4.prio = CYGNUM_HAL_INT_PRIO_5;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TCI4V,                         int_tpu4.prio,                         (cyg_addrword_t)&int_tpu4.prio,                         tpu4_ISR,                         0,                         &int_tpu4.hdl,                         &int_tpu4.obj                         );                             cyg_interrupt_attach(int_tpu4.hdl);        HAL_READ_UINT8(CYGARC_TSTR, tmp);    tmp |= CYGARC_TSTR_CST4;    HAL_WRITE_UINT8(CYGARC_TSTR, tmp);}//===========================================================================//                                TMR0 SETUP//===========================================================================void tmr0_setup(void){       //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_8TCR0, CYGARC_8TCR_CKS_8);          //    // create interrupt    //    int_tmr0.prio = CYGNUM_HAL_INT_PRIO_6;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_OVI0,                         int_tmr0.prio,                         (cyg_addrword_t)&int_tmr0.prio,                         tmr0_ISR,                         0,                         &int_tmr0.hdl,                         &int_tmr0.obj                         );                             cyg_interrupt_attach(int_tmr0.hdl);}//===========================================================================//                                TMR0 SETUP//===========================================================================void tmr1_setup(void){       //    // initialize 16 bit timer    // Clock prescaler is 1 (clock/1) so it will overflow fast    //    HAL_WRITE_UINT8(CYGARC_8TCR1, CYGARC_8TCR_CKS_8);          //    // create interrupt    //    int_tmr1.prio = CYGNUM_HAL_INT_PRIO_7;    cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_OVI1,                         int_tmr1.prio,                         (cyg_addrword_t)&int_tmr1.prio,                         tmr1_ISR,                         0,                         &int_tmr1.hdl,                         &int_tmr1.obj                         );                             cyg_interrupt_attach(int_tmr1.hdl);}//===========================================================================//                       APPLICATION MAIN STARTING POINT// DESCRIPTTION://     Main starting point for the application//===========================================================================externC void cyg_start (void ){    cyg_uint8 tmp;    CYG_TEST_INIT();         //    // start 16 bit timer module in MSTPCRH register    //    HAL_READ_UINT8(CYGARC_MSTPCRH, tmp);                        tmp &= ~CYGARC_MSTPCRH_TPU;    HAL_WRITE_UINT8(CYGARC_MSTPCRH, tmp);     //    // start 8 bit timer module in MSTPCRL register    //    HAL_READ_UINT8(CYGARC_MSTPCRL, tmp);                        tmp &= ~CYGARC_MSTPCRL_8TMR;    HAL_WRITE_UINT8(CYGARC_MSTPCRL, tmp);                                             //    // create and start threads    //    cyg_thread_create(4,                       thread_tmr_entry,                       (cyg_addrword_t) 2,                      "Thread NMI",                       (void *) thread_tmr_stack,                       4096,                      &thread_tmr_hdl,                       &thread_tmr_obj);                       cyg_thread_resume(thread_tmr_hdl);      cyg_scheduler_start();    CYG_TEST_FAIL_FINISH("Not reached");}#else   // def CYGFUN_KERNEL_API_C#define N_A_MSG "Kernel C API layer disabled"#endif  // def CYGFUN_KERNEL_API_C#ifdef N_A_MSGexternC void cyg_start( void ){    CYG_TEST_INIT();    CYG_TEST_NA( N_A_MSG);}#endif // N_A_MSG//---------------------------------------------------------------------------// End of serial1.c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -