Exemple #1
0
void init_thread(void* parameter)
{
    rt_thread_t tid;

    rt_system_comonent_init();
    rt_hw_uart_init("uart0", 0);
    rt_console_set_device("uart0");
    rt_hw_sd_init("sd0");
    rt_hw_rtc_init();
    rt_hw_spi_init();
    rt_hw_pin_init("gpio");
    rt_hw_i2c_bit_ops_bus_init("i2c0");
    at24cxx_init("at24c02", "i2c0");
    rt_hw_ads7843_init("ads7843", "spi20");
    w25qxx_init("sf0", "spi21");
    rt_hw_lcd_init("lcd0");
    
    finsh_system_init();
 //   tid = rt_thread_create("usb", usb_thread_entry, RT_NULL, 1024, 9, 20);
   // rt_thread_startup(tid);
    
    if((*(uint32_t*)0x60000) != 0xFFFFFFFF)
    {
        tid = rt_thread_create("init", (void*)(0x60000), RT_NULL, 1024, 8, 20);
        rt_thread_startup(tid);
    }
    else
    {
        printf("addr:0x%X has no application\r\n", 0x60000);
    }
    rt_hw_enet_phy_init();

    tid = rt_thread_self();
    rt_thread_delete(tid); 
}
Exemple #2
0
bool eep_init(void) {
    /* Initialize the external TWI EEPROM, and see if it is possible to read-back
     * the magic.
     */    
    if(true != at24cxx_init()) {
        at24cxx_deinit();
        return false;    
    }
    
    /* Read internal and external EEPROM magic. */
    uint8_t int_magic = 0xFF;
    EEGET(int_magic, EE_MAGIC_ADR);
    
    uint8_t ext_magic = 0xFF;
    (bool)at24cxx_read_byte(EE_MAGIC_ADR, &ext_magic);
    
    bool init_status = false;
    if (EE_MAGIC == ext_magic) {
        eep_source = EEP_SOURCE_EXTERNAL;
        init_status = true;
    } else if (EE_MAGIC == int_magic) {
        /* Save power by turning the TWI module off. */
        at24cxx_deinit();
        eep_source = EEP_SOURCE_INTERNAL;
        init_status = true;
    } else {
        /* Save power by turning the TWI module off. */
        at24cxx_deinit();
        /* No magic found. The init failed. */
        eep_source = EEP_SOURCE_UNSUPPORTED;
    }
    
    return init_status;
}