Initial implementation of the platform API for MD-UV380 target
This commit is contained in:
parent
05f180f596
commit
6e758fe92b
|
|
@ -17,46 +17,103 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <stm32f4xx.h>
|
#include <platform.h>
|
||||||
#include "platform.h"
|
#include <gpio.h>
|
||||||
#include "hwconfig.h"
|
#include "hwconfig.h"
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
/*
|
/* Configure GPIOs */
|
||||||
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
|
gpio_setMode(GREEN_LED, OUTPUT);
|
||||||
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
|
gpio_setMode(RED_LED, OUTPUT);
|
||||||
* With ARR = 256, Fpwm is 100kHz;
|
|
||||||
*/
|
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN;
|
|
||||||
TIM8->ARR = 255;
|
|
||||||
TIM8->PSC = 327;
|
|
||||||
TIM8->CNT = 0;
|
|
||||||
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
|
|
||||||
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
|
|
||||||
| TIM_CCMR1_OC1M_1
|
|
||||||
| TIM_CCMR1_OC1PE;
|
|
||||||
TIM8->CCER |= TIM_CCER_CC1E;
|
|
||||||
TIM8->BDTR |= TIM_BDTR_MOE;
|
|
||||||
TIM8->CCR1 = 0;
|
|
||||||
TIM8->EGR = TIM_EGR_UG; /* Update registers */
|
|
||||||
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
|
|
||||||
|
|
||||||
/* Configure backlight GPIO, TIM8 is on AF3 */
|
gpio_setMode(LCD_BKLIGHT, OUTPUT);
|
||||||
gpio_setMode(LCD_BKLIGHT, ALTERNATE);
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
gpio_setAlternateFunction(LCD_BKLIGHT, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
{
|
{
|
||||||
/* Shut off backlight */
|
/* Shut down backlight */
|
||||||
gpio_setMode(LCD_BKLIGHT, OUTPUT);
|
|
||||||
gpio_clearPin(LCD_BKLIGHT);
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
|
|
||||||
|
gpio_clearPin(GREEN_LED);
|
||||||
|
gpio_clearPin(RED_LED);
|
||||||
|
|
||||||
RCC->APB2ENR &= ~RCC_APB2ENR_TIM8EN;
|
RCC->APB2ENR &= ~RCC_APB2ENR_TIM8EN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float platform_getVbat()
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float platform_getMicLevel()
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float platform_getVolumeLevel()
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t platform_getChSelector()
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_ledOn(led_t led)
|
||||||
|
{
|
||||||
|
switch(led)
|
||||||
|
{
|
||||||
|
case GREEN:
|
||||||
|
gpio_setPin(GREEN_LED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RED:
|
||||||
|
gpio_setPin(RED_LED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_ledOff(led_t led)
|
||||||
|
{
|
||||||
|
switch(led)
|
||||||
|
{
|
||||||
|
case GREEN:
|
||||||
|
gpio_clearPin(GREEN_LED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RED:
|
||||||
|
gpio_clearPin(RED_LED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_beepStart(uint16_t freq)
|
||||||
|
{
|
||||||
|
(void) freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_beepStop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
void platform_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
TIM8->CCR1 = level;
|
if(level > 0)
|
||||||
|
{
|
||||||
|
gpio_setPin(LCD_BKLIGHT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue