/* * Include Files * */ #if defined(MATLAB_MEX_FILE) #include "tmwtypes.h" #include "simstruc_types.h" #else #include "rtwtypes.h" #endif /* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL #include "hal_nvram_read.h" // for parameter registration #include "param_mgr.h" // for parameter registration #endif /* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */ #define u_width 1 /* * Create external references here. * */ /* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL int is_nvram0_init = 0; int is_nvram1_init = 0; void initialize_nvram_device(uint8_t nvram_id) { if (nvram_id == 0u && !is_nvram0_init) { /* * initialize nvram device 0 here */ //is_nvram0_init = 1; } else if (nvram_id == 1u && !is_nvram1_init) { /* * initialize nvram device 1 here */ //is_nvram1_init = 1; } } #endif /* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */ /* * Start function * */ void hal_nvram_read_Start_wrapper(const uint8_T *nvram_id, const int_T p_width0) { /* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL initialize_nvram_device(nvram_id[0]); #endif /* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */ } /* * Output function * */ void hal_nvram_read_Outputs_wrapper(const uint32_T *address, const uint16_T *read_len, uint8_T *buffer, int32_T *ErrorCode, const uint8_T *nvram_id, const int_T p_width0, const int_T y_width) { /* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */ #ifdef HAL_IMPL /* **************************************** * read from NAVRAM device * this call should return immediately, so it's better to state the * backgournd task to do the real work. * * inputs: * address - Starting address to be read * read_len - maxium bytes to be read * * outputs: * buffer - read data to buffer * ErrorCode - return 0 when read complete, otherwise * return remaining length when readling uncompletly, * return -1 on genral failures. * return -2 on busy(ocuppied). * return -3 on cancelled. * * parameter: * nvram_id - NV-RAM device/proxy ID * * constant: * y_width - the size of buffer, do not write overflow. */ ErrorCode[0] = -1; switch (nvram_id[0]) { case 0: if (is_nvram0_init) { //TODO //ErrorCode[0] = 0; } break; case 1: if (is_nvram1_init) { //TODO //ErrorCode[0] = 0; } break; } #else ErrorCode[0] = 0; #endif /* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */ }