|
@@ -1,84 +0,0 @@
|
|
|
-
|
|
|
-Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
|
|
|
-Jun Wako <wakojun@gmail.com>
|
|
|
-
|
|
|
-This program is free software: you can redistribute it and/or modify
|
|
|
-it under the terms of the GNU General Public License as published by
|
|
|
-the Free Software Foundation, either version 2 of the License, or
|
|
|
-(at your option) any later version.
|
|
|
-
|
|
|
-This program is distributed in the hope that it will be useful,
|
|
|
-but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-GNU General Public License for more details.
|
|
|
-
|
|
|
-You should have received a copy of the GNU General Public License
|
|
|
-along with this program. If not, see <http:
|
|
|
-*/
|
|
|
-#include "lcd_backlight.h"
|
|
|
-#include "hal.h"
|
|
|
-
|
|
|
-#define RED_PIN 1
|
|
|
-#define GREEN_PIN 2
|
|
|
-#define BLUE_PIN 3
|
|
|
-#define CHANNEL_RED FTM0->CHANNEL[0]
|
|
|
-#define CHANNEL_GREEN FTM0->CHANNEL[1]
|
|
|
-#define CHANNEL_BLUE FTM0->CHANNEL[2]
|
|
|
-
|
|
|
-#define RGB_PORT PORTC
|
|
|
-#define RGB_PORT_GPIO GPIOC
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#define PRESCALAR_DEFINE 0
|
|
|
-
|
|
|
-void lcd_backlight_hal_init(void) {
|
|
|
-
|
|
|
- SIM->SCGC6 |= SIM_SCGC6_FTM0;
|
|
|
- FTM0->CNT = 0;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- FTM0->MOD = 0xFFFF;
|
|
|
-
|
|
|
-
|
|
|
-#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
|
|
|
- CHANNEL_RED.CnSC = CNSC_MODE;
|
|
|
- CHANNEL_GREEN.CnSC = CNSC_MODE;
|
|
|
- CHANNEL_BLUE.CnSC = CNSC_MODE;
|
|
|
-
|
|
|
-
|
|
|
- FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
|
|
|
-
|
|
|
- CHANNEL_RED.CnV = 0;
|
|
|
- CHANNEL_GREEN.CnV = 0;
|
|
|
- CHANNEL_BLUE.CnV = 0;
|
|
|
-
|
|
|
- RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
|
|
|
- RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
|
|
|
- RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
|
|
|
-
|
|
|
-#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
|
|
|
- RGB_PORT->PCR[RED_PIN] = RGB_MODE;
|
|
|
- RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
|
|
|
- RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
|
|
|
-}
|
|
|
-
|
|
|
-void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
|
|
|
- CHANNEL_RED.CnV = r;
|
|
|
- CHANNEL_GREEN.CnV = g;
|
|
|
- CHANNEL_BLUE.CnV = b;
|
|
|
-}
|
|
|
-
|