mirror of
https://github.com/egzumer/uv-k5-firmware-custom
synced 2024-11-22 01:32:43 +00:00
Refactor
This commit is contained in:
parent
20a3e3b605
commit
5d4f7529ed
26
board.c
26
board.c
@ -23,11 +23,10 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "bsp/dp32g030/gpio.h"
|
||||||
#include "bsp/dp32g030/portcon.h"
|
#include "bsp/dp32g030/portcon.h"
|
||||||
#include "bsp/dp32g030/pwmplus.h"
|
|
||||||
#include "bsp/dp32g030/saradc.h"
|
#include "bsp/dp32g030/saradc.h"
|
||||||
#include "bsp/dp32g030/syscon.h"
|
#include "bsp/dp32g030/syscon.h"
|
||||||
#include "driver/adc.h"
|
#include "driver/adc.h"
|
||||||
//#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "driver/bk1080.h"
|
#include "driver/bk1080.h"
|
||||||
#endif
|
#endif
|
||||||
@ -182,14 +181,10 @@ void BOARD_PORTCON_Init(void)
|
|||||||
// PORT B pin selection
|
// PORT B pin selection
|
||||||
|
|
||||||
PORTCON_PORTB_SEL0 &= ~(0
|
PORTCON_PORTB_SEL0 &= ~(0
|
||||||
// Back light
|
|
||||||
| PORTCON_PORTB_SEL0_B6_MASK
|
|
||||||
// SPI0 SSN
|
// SPI0 SSN
|
||||||
| PORTCON_PORTB_SEL0_B7_MASK
|
| PORTCON_PORTB_SEL0_B7_MASK
|
||||||
);
|
);
|
||||||
PORTCON_PORTB_SEL0 |= 0
|
PORTCON_PORTB_SEL0 |= 0
|
||||||
// Back light PWM
|
|
||||||
| PORTCON_PORTB_SEL0_B6_BITS_PWMP0_CH0
|
|
||||||
// SPI0 SSN
|
// SPI0 SSN
|
||||||
| PORTCON_PORTB_SEL0_B7_BITS_SPI0_SSN
|
| PORTCON_PORTB_SEL0_B7_BITS_SPI0_SSN
|
||||||
;
|
;
|
||||||
@ -470,23 +465,6 @@ void BOARD_PORTCON_Init(void)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BacklightPWM_Init()
|
|
||||||
{
|
|
||||||
// 48MHz / 94 / 1024 ~ 500Hz
|
|
||||||
PWM_PLUS0_CLKSRC |= ((94) << 16);
|
|
||||||
PWM_PLUS0_PERIOD = 1023;
|
|
||||||
|
|
||||||
PWM_PLUS0_GEN =
|
|
||||||
PWMPLUS_GEN_CH0_OE_BITS_ENABLE |
|
|
||||||
PWMPLUS_GEN_CH0_OUTINV_BITS_ENABLE |
|
|
||||||
0;
|
|
||||||
|
|
||||||
PWM_PLUS0_CFG =
|
|
||||||
PWMPLUS_CFG_CNT_REP_BITS_ENABLE |
|
|
||||||
PWMPLUS_CFG_COUNTER_EN_BITS_ENABLE |
|
|
||||||
0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BOARD_ADC_Init(void)
|
void BOARD_ADC_Init(void)
|
||||||
{
|
{
|
||||||
ADC_Config_t Config;
|
ADC_Config_t Config;
|
||||||
@ -524,7 +502,7 @@ void BOARD_Init(void)
|
|||||||
{
|
{
|
||||||
BOARD_PORTCON_Init();
|
BOARD_PORTCON_Init();
|
||||||
BOARD_GPIO_Init();
|
BOARD_GPIO_Init();
|
||||||
BacklightPWM_Init();
|
BACKLIGHT_InitHardware();
|
||||||
BOARD_ADC_Init();
|
BOARD_ADC_Init();
|
||||||
ST7565_Init(true);
|
ST7565_Init(true);
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "bsp/dp32g030/gpio.h"
|
#include "bsp/dp32g030/gpio.h"
|
||||||
#include "bsp/dp32g030/pwmplus.h"
|
#include "bsp/dp32g030/pwmplus.h"
|
||||||
|
#include "bsp/dp32g030/portcon.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -24,6 +25,33 @@
|
|||||||
uint16_t gBacklightCountdown = 0;
|
uint16_t gBacklightCountdown = 0;
|
||||||
bool backlightOn;
|
bool backlightOn;
|
||||||
|
|
||||||
|
void BACKLIGHT_InitHardware()
|
||||||
|
{
|
||||||
|
// 48MHz / 94 / 1024 ~ 500Hz
|
||||||
|
const uint32_t PWM_FREQUENCY_HZ = 500;
|
||||||
|
PWM_PLUS0_CLKSRC |= ((48000000 / 1024 / PWM_FREQUENCY_HZ) << 16);
|
||||||
|
PWM_PLUS0_PERIOD = 1023;
|
||||||
|
|
||||||
|
PORTCON_PORTB_SEL0 &= ~(0
|
||||||
|
// Back light
|
||||||
|
| PORTCON_PORTB_SEL0_B6_MASK
|
||||||
|
);
|
||||||
|
PORTCON_PORTB_SEL0 |= 0
|
||||||
|
// Back light PWM
|
||||||
|
| PORTCON_PORTB_SEL0_B6_BITS_PWMP0_CH0
|
||||||
|
;
|
||||||
|
|
||||||
|
PWM_PLUS0_GEN =
|
||||||
|
PWMPLUS_GEN_CH0_OE_BITS_ENABLE |
|
||||||
|
PWMPLUS_GEN_CH0_OUTINV_BITS_ENABLE |
|
||||||
|
0;
|
||||||
|
|
||||||
|
PWM_PLUS0_CFG =
|
||||||
|
PWMPLUS_CFG_CNT_REP_BITS_ENABLE |
|
||||||
|
PWMPLUS_CFG_COUNTER_EN_BITS_ENABLE |
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
|
||||||
void BACKLIGHT_TurnOn(void)
|
void BACKLIGHT_TurnOn(void)
|
||||||
{
|
{
|
||||||
if (gEeprom.BACKLIGHT_TIME != 0) {
|
if (gEeprom.BACKLIGHT_TIME != 0) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
extern uint16_t gBacklightCountdown;
|
extern uint16_t gBacklightCountdown;
|
||||||
extern uint8_t gBacklightBrightness;
|
extern uint8_t gBacklightBrightness;
|
||||||
|
|
||||||
|
void BACKLIGHT_InitHardware();
|
||||||
void BACKLIGHT_TurnOn();
|
void BACKLIGHT_TurnOn();
|
||||||
void BACKLIGHT_TurnOff();
|
void BACKLIGHT_TurnOff();
|
||||||
bool BACKLIGHT_IsOn();
|
bool BACKLIGHT_IsOn();
|
||||||
|
Loading…
Reference in New Issue
Block a user