diff --git a/openrtx/include/interfaces/platform.h b/openrtx/include/interfaces/platform.h index d2a8ca9a..fdb64f8e 100644 --- a/openrtx/include/interfaces/platform.h +++ b/openrtx/include/interfaces/platform.h @@ -108,4 +108,11 @@ void platform_beepStop(); */ void platform_setBacklightLevel(uint8_t level); +/** + * This function returns a pointer to the device-specific calbration data, + * application code has to cast it to the correct data structure. + * @return pointer to device's calibration data. + */ +const void *platform_getCalibrationData(); + #endif /* PLATFORM_H */ diff --git a/platform/targets/MD-380/platform.c b/platform/targets/MD-380/platform.c index e5cda1ae..4e3f8be9 100644 --- a/platform/targets/MD-380/platform.c +++ b/platform/targets/MD-380/platform.c @@ -19,8 +19,12 @@ #include #include -#include "hwconfig.h" -#include "ADC1_MDx.h" +#include +#include +#include +#include + +md3x0Calib_t calibration; void platform_init() { @@ -67,6 +71,12 @@ void platform_init() TIM8->CCR1 = 0; TIM8->EGR = TIM_EGR_UG; /* Update registers */ TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */ + + /* + * Initialise non volatile memory manager and load calibration data. + */ + nvm_init(); + nvm_readCalibData(&calibration); } void platform_terminate() @@ -85,6 +95,9 @@ void platform_terminate() /* Shut down ADC */ adc1_terminate(); + + /* Shut down NVM driver */ + nvm_terminate(); } float platform_getVbat() @@ -173,3 +186,8 @@ void platform_setBacklightLevel(uint8_t level) { TIM8->CCR1 = level; } + +const void *platform_getCalibrationData() +{ + return ((const void *) &calibration); +} diff --git a/platform/targets/MD-390/platform.c b/platform/targets/MD-390/platform.c index e5cda1ae..4e3f8be9 100644 --- a/platform/targets/MD-390/platform.c +++ b/platform/targets/MD-390/platform.c @@ -19,8 +19,12 @@ #include #include -#include "hwconfig.h" -#include "ADC1_MDx.h" +#include +#include +#include +#include + +md3x0Calib_t calibration; void platform_init() { @@ -67,6 +71,12 @@ void platform_init() TIM8->CCR1 = 0; TIM8->EGR = TIM_EGR_UG; /* Update registers */ TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */ + + /* + * Initialise non volatile memory manager and load calibration data. + */ + nvm_init(); + nvm_readCalibData(&calibration); } void platform_terminate() @@ -85,6 +95,9 @@ void platform_terminate() /* Shut down ADC */ adc1_terminate(); + + /* Shut down NVM driver */ + nvm_terminate(); } float platform_getVbat() @@ -173,3 +186,8 @@ void platform_setBacklightLevel(uint8_t level) { TIM8->CCR1 = level; } + +const void *platform_getCalibrationData() +{ + return ((const void *) &calibration); +} diff --git a/platform/targets/MD-UV380/platform.c b/platform/targets/MD-UV380/platform.c index 72ec8808..3ffebd3e 100644 --- a/platform/targets/MD-UV380/platform.c +++ b/platform/targets/MD-UV380/platform.c @@ -20,8 +20,12 @@ #include #include #include -#include "hwconfig.h" -#include "ADC1_MDx.h" +#include +#include +#include +#include + +mduv3x0Calib_t calibration; #ifdef ENABLE_BKLIGHT_DIMMING void TIM1_TRG_COM_TIM11_IRQHandler() @@ -94,6 +98,12 @@ void platform_init() NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn,15); NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn); #endif + + /* + * Initialise non volatile memory manager and load calibration data. + */ + nvm_init(); + nvm_readCalibData(&calibration); } void platform_terminate() @@ -112,6 +122,9 @@ void platform_terminate() /* Shut down ADC */ adc1_terminate(); + + /* Shut down NVM driver */ + nvm_terminate(); } float platform_getVbat() @@ -218,3 +231,8 @@ void platform_setBacklightLevel(uint8_t level) gpio_clearPin(LCD_BKLIGHT); } } + +const void *platform_getCalibrationData() +{ + return ((const void *) &calibration); +} diff --git a/platform/targets/linux/platform.c b/platform/targets/linux/platform.c index 534c2840..5efbef68 100644 --- a/platform/targets/linux/platform.c +++ b/platform/targets/linux/platform.c @@ -22,77 +22,92 @@ void platform_init() { - //printf("Platform init\n"); + //printf("Platform init\n"); } void platform_terminate() { - printf("Platform terminate\n"); + printf("Platform terminate\n"); } void platform_setBacklightLevel(uint8_t level) { - //printf("platform_setBacklightLevel(%u)\n", level); + //printf("platform_setBacklightLevel(%u)\n", level); } // Simulate a fully charged lithium battery -float platform_getVbat(){ - return Radio_State.Vbat; +float platform_getVbat() +{ + return Radio_State.Vbat; } -float platform_getMicLevel(){ - return Radio_State.micLevel; +float platform_getMicLevel() +{ + return Radio_State.micLevel; } -float platform_getVolumeLevel(){ - return Radio_State.volumeLevel; +float platform_getVolumeLevel() +{ + return Radio_State.volumeLevel; } -uint8_t platform_getChSelector(){ - return Radio_State.chSelector; +uint8_t platform_getChSelector() +{ + return Radio_State.chSelector; } -bool platform_getPttStatus(){ +bool platform_getPttStatus() +{ return Radio_State.PttStatus; } -void platform_ledOn(led_t led){ - char* str; +void platform_ledOn(led_t led) +{ + char* str; - switch(led){ - case 0: - str = "GREEN"; - break; - case 1: - str = "RED"; - break; - case 2: - str = "YELLOW"; - break; - case 3: - str = "WHITE"; - break; - } + switch(led) + { + case 0: + str = "GREEN"; + break; + case 1: + str = "RED"; + break; + case 2: + str = "YELLOW"; + break; + case 3: + str = "WHITE"; + break; + } - printf("platform_ledOn(%s)\n", str); + printf("platform_ledOn(%s)\n", str); } -void platform_ledOff(led_t led){ - printf("platform_ledOff()\n"); +void platform_ledOff(led_t led) +{ + printf("platform_ledOff()\n"); } -void platform_beepStart(uint16_t freq){ - printf("platform_beepStart(%u)\n", freq); +void platform_beepStart(uint16_t freq) +{ + printf("platform_beepStart(%u)\n", freq); } -void platform_beepStop(){ - printf("platform_beepStop()\n"); +void platform_beepStop() +{ + printf("platform_beepStop()\n"); +} + +const void *platform_getCalibrationData() +{ + return NULL; }