void node_main(void) { uint8_t status; /* TODO load listening address from flash. */ uint8_t thisAddr[5]= {97, 89, 64, 222, 121}; init_stdio_USART2(); init_delay(); SPI2_Init(); delay_ms(10); nrf24l01Init(); delay_ms(100); status = nRF24_Check(); if (status == 1) { for (;;); } printf("nRF check OK!\n"); nrfSetRxMode(92, 5, thisAddr); init_node_link(); printf("init_node_link OK!\n"); nRF_Task_Init(); /* From now on, controls and sensors can be initialized. */ init_switches(); printf("init_switches OK!\n"); for (;;) { nRF_Task_Loop(); delay_ms(1); } }
//Initialize all the peripherals void init_peripherals(void) { //Hardware modules: init_systick_timer(); //SysTick timer init_usart1(2000000); //USART1 (RS-485 #1) init_usart6(2000000); //USART6 (RS-485 #2) init_rs485_outputs(); init_leds(); init_switches(); init_dio(); //All inputs by default init_adc1(); init_spi4(); //Plan //init_spi5(); //FLASH //init_spi6(); //Expansion init_i2c1(); init_imu(); init_adva_fc_pins(); init_pwr_out(); //Software: init_master_slave_comm(); //All RGB LEDs OFF LEDR(0); LEDG(0); LEDB(0); //Default analog input states: set_default_analog(); }
/*---------------------------------------------------------------------------- MAIN function *----------------------------------------------------------------------------*/ int main(void){ //Initialise LEDs, buttons and interrupts init_RGB(); init_switches(); init_interrupts(); done = 0; while(1){ switch(done){ //Toggle corresponding bits depending on which button was pressed case 1: toggle_r(); break; case 2: toggle_g(); break; case 3: toggle_b(); break; case 4: toggle_all(); break; } done = 0; delay(1); if (done == 0) //if done == 0, processor goes to sleep __wfi(); } }
int fpga_build_model(struct fpga_model* model, int fpga_rows, const char* columns, const char* left_wiring, const char* right_wiring) { int rc; memset(model, 0, sizeof(*model)); model->cfg_rows = fpga_rows; strncpy(model->cfg_columns, columns, sizeof(model->cfg_columns)-1); strncpy(model->cfg_left_wiring, left_wiring, sizeof(model->cfg_left_wiring)-1); strncpy(model->cfg_right_wiring, right_wiring, sizeof(model->cfg_right_wiring)-1); strarray_init(&model->str, STRIDX_64K); rc = get_xc6_routing_bitpos(&model->sw_bitpos, &model->num_bitpos); if (rc) FAIL(rc); // The order of tiles, then devices, then ports, then // connections and finally switches is important so // that the codes can build upon each other. rc = init_tiles(model); if (rc) FAIL(rc); rc = init_devices(model); if (rc) FAIL(rc); if (s_high_speed_replicate) { rc = replicate_routing_switches(model); if (rc) FAIL(rc); } // todo: compare.ports only works if other switches and conns // are disabled, as long as not all connections are supported rc = init_ports(model, /*dup_warn*/ !s_high_speed_replicate); if (rc) FAIL(rc); rc = init_conns(model); if (rc) FAIL(rc); rc = init_switches(model, /*routing_sw*/ !s_high_speed_replicate); if (rc) FAIL(rc); return 0; fail: return rc; }
int main (int argc, char **argv) { init_switches (); return 0; }