kopia lustrzana https://github.com/OpenRTX/OpenRTX
Implementing the remaining API specified in platform.h for MD380 target
rodzic
8b7ec5b4ce
commit
05f180f596
|
@ -99,10 +99,10 @@ md380_src = src + ['openrtx/src/main.c',
|
|||
'platform/mcu/STM32F4xx/drivers/gpio.c',
|
||||
'platform/mcu/STM32F4xx/drivers/usb_vcom.c',
|
||||
'platform/mcu/STM32F4xx/drivers/delays.c',
|
||||
'platform/mcu/STM32F4xx/drivers/gpio.c',
|
||||
'platform/mcu/CMSIS/Device/ST/STM32F4xx/Source/system_stm32f4xx.c',
|
||||
'platform/drivers/display/HX83XX_md380.c',
|
||||
'platform/targets/MD380/platform.c',
|
||||
'platform/targets/MD380/adc1.c',
|
||||
'openrtx/src/graphics/graphics_rgb565.c',
|
||||
'rtos/uC-OS3/Ports/ARM-Cortex-M/ARMv7-M/os_cpu_c.c',
|
||||
'rtos/uC-OS3/Ports/ARM-Cortex-M/ARMv7-M/os_cpu_a.s',
|
||||
|
@ -114,6 +114,7 @@ md380_def = def + {'STM32F40_41xxx': ''}
|
|||
md380_inc = inc + ['platform/mcu/CMSIS/Include',
|
||||
'platform/mcu/CMSIS/Device/ST/STM32F4xx/Include',
|
||||
'platform/mcu/STM32F4xx',
|
||||
'platform/mcu/STM32F4xx/drivers',
|
||||
'platform/mcu/STM32F4xx/drivers/usb',
|
||||
'platform/targets/MD380',
|
||||
'rtos/uC-OS3/Ports/ARM-Cortex-M/ARMv7-M',
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <gpio.h>
|
||||
#include "hwconfig.h"
|
||||
#include "adc1.h"
|
||||
#include "gpio.h"
|
||||
|
||||
uint16_t measurements[4];
|
||||
|
||||
|
@ -32,10 +33,10 @@ void adc1_init()
|
|||
* - PA3: vox level
|
||||
* - PB0: RSSI level
|
||||
*/
|
||||
gpio_setMode(GPIOA, 0, INPUT_ANALOG);
|
||||
gpio_setMode(GPIOA, 1, INPUT_ANALOG);
|
||||
gpio_setMode(GPIOA, 3, INPUT_ANALOG);
|
||||
gpio_setMode(GPIOB, 0, INPUT_ANALOG);
|
||||
gpio_setMode(AIN_VOLUME, INPUT_ANALOG);
|
||||
gpio_setMode(AIN_VBAT, INPUT_ANALOG);
|
||||
gpio_setMode(AIN_MIC, INPUT_ANALOG);
|
||||
gpio_setMode(AIN_RSSI, INPUT_ANALOG);
|
||||
|
||||
/*
|
||||
* ADC clock is APB2 frequency divided by 8, giving 10.5MHz.
|
||||
|
@ -89,7 +90,7 @@ void adc1_init()
|
|||
ADC1->CR2 |= ADC_CR2_SWSTART;
|
||||
}
|
||||
|
||||
void adc1_shutdown()
|
||||
void adc1_terminate()
|
||||
{
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN;
|
||||
ADC1->CR2 &= ADC_CR2_ADON;
|
|
@ -19,7 +19,6 @@
|
|||
#define ADC1_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
/**
|
||||
* Driver for ADC1, used to continuously sample the following channels:
|
||||
|
@ -45,7 +44,7 @@ void adc1_init();
|
|||
* Turn off ADC1 (also gating off its clock) and disable DMA2 Stream 0.
|
||||
* DMA2 clock is kept active.
|
||||
*/
|
||||
void adc1_shutdown();
|
||||
void adc1_terminate();
|
||||
|
||||
/**
|
||||
* Get current measurement of a given channel, mapped as below:
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef HWCONFIG_H
|
||||
#define HWCONFIG_H
|
||||
|
||||
#include "stm32f4xx.h"
|
||||
#include <stm32f4xx.h>
|
||||
|
||||
/* Screen dimensions */
|
||||
#define SCREEN_WIDTH 160
|
||||
|
@ -43,4 +43,12 @@
|
|||
|
||||
#define LCD_BKLIGHT GPIOC,6
|
||||
|
||||
#define GREEN_LED GPIOE,0
|
||||
#define RED_LED GPIOE,1
|
||||
|
||||
#define AIN_VOLUME GPIOA,0
|
||||
#define AIN_VBAT GPIOA,1
|
||||
#define AIN_MIC GPIOA,3
|
||||
#define AIN_RSSI GPIOB,0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,13 +17,24 @@
|
|||
* 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 "gpio.h"
|
||||
#include "adc1.h"
|
||||
|
||||
void platform_init()
|
||||
{
|
||||
/* Configure GPIOs */
|
||||
gpio_setMode(GREEN_LED, OUTPUT);
|
||||
gpio_setMode(RED_LED, OUTPUT);
|
||||
|
||||
/* Backlight pin connected to TIM8 CR1 */
|
||||
gpio_setMode(LCD_BKLIGHT, ALTERNATE);
|
||||
gpio_setAlternateFunction(LCD_BKLIGHT, 3);
|
||||
|
||||
/* Initialise ADC1, for vbat, RSSI, ... */
|
||||
adc1_init();
|
||||
|
||||
/*
|
||||
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
|
||||
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
|
||||
|
@ -42,18 +53,86 @@ void platform_init()
|
|||
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, ALTERNATE);
|
||||
gpio_setAlternateFunction(LCD_BKLIGHT, 3);
|
||||
}
|
||||
|
||||
void platform_terminate()
|
||||
{
|
||||
/* Shut off backlight */
|
||||
/* Shut down backlight */
|
||||
gpio_setMode(LCD_BKLIGHT, OUTPUT);
|
||||
gpio_clearPin(LCD_BKLIGHT);
|
||||
|
||||
gpio_clearPin(GREEN_LED);
|
||||
gpio_clearPin(RED_LED);
|
||||
|
||||
/* Shut down timer */
|
||||
RCC->APB2ENR &= ~RCC_APB2ENR_TIM8EN;
|
||||
|
||||
/* Shut down ADC */
|
||||
adc1_terminate();
|
||||
}
|
||||
|
||||
float platform_getVbat()
|
||||
{
|
||||
return adc1_getMeasurement(0);
|
||||
}
|
||||
|
||||
float platform_getMicLevel()
|
||||
{
|
||||
return adc1_getMeasurement(2);
|
||||
}
|
||||
|
||||
float platform_getVolumeLevel()
|
||||
{
|
||||
return adc1_getMeasurement(3);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Ładowanie…
Reference in New Issue