Added to platform API a function allowing to retrieve device calibration data
This commit is contained in:
parent
d4cdba2243
commit
774468ae46
|
|
@ -108,4 +108,11 @@ void platform_beepStop();
|
||||||
*/
|
*/
|
||||||
void platform_setBacklightLevel(uint8_t level);
|
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 */
|
#endif /* PLATFORM_H */
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,12 @@
|
||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include "hwconfig.h"
|
#include <hwconfig.h>
|
||||||
#include "ADC1_MDx.h"
|
#include <ADC1_MDx.h>
|
||||||
|
#include <calibInfo_MDx.h>
|
||||||
|
#include <nvmem.h>
|
||||||
|
|
||||||
|
md3x0Calib_t calibration;
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
|
|
@ -67,6 +71,12 @@ void platform_init()
|
||||||
TIM8->CCR1 = 0;
|
TIM8->CCR1 = 0;
|
||||||
TIM8->EGR = TIM_EGR_UG; /* Update registers */
|
TIM8->EGR = TIM_EGR_UG; /* Update registers */
|
||||||
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
|
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise non volatile memory manager and load calibration data.
|
||||||
|
*/
|
||||||
|
nvm_init();
|
||||||
|
nvm_readCalibData(&calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -85,6 +95,9 @@ void platform_terminate()
|
||||||
|
|
||||||
/* Shut down ADC */
|
/* Shut down ADC */
|
||||||
adc1_terminate();
|
adc1_terminate();
|
||||||
|
|
||||||
|
/* Shut down NVM driver */
|
||||||
|
nvm_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
float platform_getVbat()
|
float platform_getVbat()
|
||||||
|
|
@ -173,3 +186,8 @@ void platform_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
TIM8->CCR1 = level;
|
TIM8->CCR1 = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void *platform_getCalibrationData()
|
||||||
|
{
|
||||||
|
return ((const void *) &calibration);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,12 @@
|
||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include "hwconfig.h"
|
#include <hwconfig.h>
|
||||||
#include "ADC1_MDx.h"
|
#include <ADC1_MDx.h>
|
||||||
|
#include <calibInfo_MDx.h>
|
||||||
|
#include <nvmem.h>
|
||||||
|
|
||||||
|
md3x0Calib_t calibration;
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
|
|
@ -67,6 +71,12 @@ void platform_init()
|
||||||
TIM8->CCR1 = 0;
|
TIM8->CCR1 = 0;
|
||||||
TIM8->EGR = TIM_EGR_UG; /* Update registers */
|
TIM8->EGR = TIM_EGR_UG; /* Update registers */
|
||||||
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
|
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise non volatile memory manager and load calibration data.
|
||||||
|
*/
|
||||||
|
nvm_init();
|
||||||
|
nvm_readCalibData(&calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -85,6 +95,9 @@ void platform_terminate()
|
||||||
|
|
||||||
/* Shut down ADC */
|
/* Shut down ADC */
|
||||||
adc1_terminate();
|
adc1_terminate();
|
||||||
|
|
||||||
|
/* Shut down NVM driver */
|
||||||
|
nvm_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
float platform_getVbat()
|
float platform_getVbat()
|
||||||
|
|
@ -173,3 +186,8 @@ void platform_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
TIM8->CCR1 = level;
|
TIM8->CCR1 = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void *platform_getCalibrationData()
|
||||||
|
{
|
||||||
|
return ((const void *) &calibration);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,12 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include <os.h>
|
#include <os.h>
|
||||||
#include "hwconfig.h"
|
#include <hwconfig.h>
|
||||||
#include "ADC1_MDx.h"
|
#include <ADC1_MDx.h>
|
||||||
|
#include <calibInfo_MDx.h>
|
||||||
|
#include <nvmem.h>
|
||||||
|
|
||||||
|
mduv3x0Calib_t calibration;
|
||||||
|
|
||||||
#ifdef ENABLE_BKLIGHT_DIMMING
|
#ifdef ENABLE_BKLIGHT_DIMMING
|
||||||
void TIM1_TRG_COM_TIM11_IRQHandler()
|
void TIM1_TRG_COM_TIM11_IRQHandler()
|
||||||
|
|
@ -94,6 +98,12 @@ void platform_init()
|
||||||
NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn,15);
|
NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn,15);
|
||||||
NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn);
|
NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise non volatile memory manager and load calibration data.
|
||||||
|
*/
|
||||||
|
nvm_init();
|
||||||
|
nvm_readCalibData(&calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -112,6 +122,9 @@ void platform_terminate()
|
||||||
|
|
||||||
/* Shut down ADC */
|
/* Shut down ADC */
|
||||||
adc1_terminate();
|
adc1_terminate();
|
||||||
|
|
||||||
|
/* Shut down NVM driver */
|
||||||
|
nvm_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
float platform_getVbat()
|
float platform_getVbat()
|
||||||
|
|
@ -218,3 +231,8 @@ void platform_setBacklightLevel(uint8_t level)
|
||||||
gpio_clearPin(LCD_BKLIGHT);
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void *platform_getCalibrationData()
|
||||||
|
{
|
||||||
|
return ((const void *) &calibration);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,77 +22,92 @@
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
//printf("Platform init\n");
|
//printf("Platform init\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
{
|
{
|
||||||
printf("Platform terminate\n");
|
printf("Platform terminate\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
void platform_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
//printf("platform_setBacklightLevel(%u)\n", level);
|
//printf("platform_setBacklightLevel(%u)\n", level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate a fully charged lithium battery
|
// Simulate a fully charged lithium battery
|
||||||
float platform_getVbat(){
|
float platform_getVbat()
|
||||||
return Radio_State.Vbat;
|
{
|
||||||
|
return Radio_State.Vbat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float platform_getMicLevel(){
|
float platform_getMicLevel()
|
||||||
return Radio_State.micLevel;
|
{
|
||||||
|
return Radio_State.micLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float platform_getVolumeLevel(){
|
float platform_getVolumeLevel()
|
||||||
return Radio_State.volumeLevel;
|
{
|
||||||
|
return Radio_State.volumeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t platform_getChSelector(){
|
uint8_t platform_getChSelector()
|
||||||
return Radio_State.chSelector;
|
{
|
||||||
|
return Radio_State.chSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool platform_getPttStatus(){
|
bool platform_getPttStatus()
|
||||||
|
{
|
||||||
return Radio_State.PttStatus;
|
return Radio_State.PttStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void platform_ledOn(led_t led){
|
void platform_ledOn(led_t led)
|
||||||
char* str;
|
{
|
||||||
|
char* str;
|
||||||
|
|
||||||
switch(led){
|
switch(led)
|
||||||
case 0:
|
{
|
||||||
str = "GREEN";
|
case 0:
|
||||||
break;
|
str = "GREEN";
|
||||||
case 1:
|
break;
|
||||||
str = "RED";
|
case 1:
|
||||||
break;
|
str = "RED";
|
||||||
case 2:
|
break;
|
||||||
str = "YELLOW";
|
case 2:
|
||||||
break;
|
str = "YELLOW";
|
||||||
case 3:
|
break;
|
||||||
str = "WHITE";
|
case 3:
|
||||||
break;
|
str = "WHITE";
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
printf("platform_ledOn(%s)\n", str);
|
printf("platform_ledOn(%s)\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void platform_ledOff(led_t led){
|
void platform_ledOff(led_t led)
|
||||||
printf("platform_ledOff()\n");
|
{
|
||||||
|
printf("platform_ledOff()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void platform_beepStart(uint16_t freq){
|
void platform_beepStart(uint16_t freq)
|
||||||
printf("platform_beepStart(%u)\n", freq);
|
{
|
||||||
|
printf("platform_beepStart(%u)\n", freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void platform_beepStop(){
|
void platform_beepStop()
|
||||||
printf("platform_beepStop()\n");
|
{
|
||||||
|
printf("platform_beepStop()\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *platform_getCalibrationData()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue