void system_init(void) { hal_sys_init(); hal_i2c_init(); usb_uart_init(); tmp245_init(); /* initialize system lock */ syslock = xSemaphoreCreateMutex(); set_configuration(ADC_INPUT_VOLTAGE_DC, ADC_RANGE_300, ADC_INTEGRATION_50HZ, ADC_CHANNEL_0, 1, 0, ADC_RESOLUTION_5_5); }
extern hal_result_t hal_core_init(const hal_core_cfg_t *cfg) { if(NULL == cfg) { hal_base_on_fatalerror(hal_fatalerror_missingconfiguration, "hal_core_init() needs cfg"); return(hal_res_NOK_generic); } if(hal_core_status_zero != s_hal_core_theinternals.status) { hal_base_on_fatalerror(hal_fatalerror_generic, "hal_core_init() already called"); return(hal_res_NOK_generic); } // sets used config. it may be used to retrieve params for hal_cpu_init() and hal_sys_init() memcpy(&s_hal_core_theinternals.config, cfg, sizeof(hal_core_cfg_t)); // call something which prepares memory in core modules s_hal_core_modules_in_core_static_memory_init(); // call something which prepares memory of other modules specified in brdcfg s_hal_core_modules_in_brdcfg_static_memory_init(); // -- call initialisation of base hal_base_init(&cfg->basecfg); // -- call initialisation of cpu hal_cpu_init(&cfg->cpucfg); // -- call initialisation of flash hal_flash_init(&cfg->flashcfg); // -- call initialisation of sys hal_sys_init(&cfg->syscfg); // sets initialisation done s_hal_core_theinternals.status = hal_core_status_initialised; return(hal_res_OK); }
// -------------------------------------------------------------------------------------------------------------------- // - definition of static functions // -------------------------------------------------------------------------------------------------------------------- void s_my_init(void *p, uint32_t u) { hal_can_frame_t frame; hal_result_t res; s_led_init(); hal_sys_init(&s_hal_syscfg); s_can_init(); frame.id = 0x12; frame.id_type = hal_can_frameID_std; frame.frame_type = hal_can_frame_data; frame.size = 8; memcpy(frame.data, s_start_str, 5); res = hal_can_put(&frame, hal_send_now); s_led_flash(); }