Refactor
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "backlight.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "bsp/dp32g030/pwmplus.h"
|
||||
#include "bsp/dp32g030/portcon.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "settings.h"
|
||||
|
||||
@@ -24,6 +25,33 @@
|
||||
uint16_t gBacklightCountdown = 0;
|
||||
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)
|
||||
{
|
||||
if (gEeprom.BACKLIGHT_TIME != 0) {
|
||||
|
@@ -23,6 +23,7 @@
|
||||
extern uint16_t gBacklightCountdown;
|
||||
extern uint8_t gBacklightBrightness;
|
||||
|
||||
void BACKLIGHT_InitHardware();
|
||||
void BACKLIGHT_TurnOn();
|
||||
void BACKLIGHT_TurnOff();
|
||||
bool BACKLIGHT_IsOn();
|
||||
|
Reference in New Issue
Block a user