Add overtemperature shutdown
This commit is contained in:
parent
d9769e7b34
commit
93d15fc549
@ -4,6 +4,7 @@
|
||||
#include <ring-light/temp-adc.h>
|
||||
|
||||
#define RING_MAX_LED 32u
|
||||
#define MAX_TEMP_CELSIUS 70
|
||||
|
||||
enum ring_modes {
|
||||
RING_MODE_ALL, /*!< control all LEDs at once */
|
||||
@ -63,30 +64,37 @@ int main(void)
|
||||
TIM3->PSC = 0;
|
||||
TIM3->CR1 = TIM_CR1_CEN;
|
||||
|
||||
/*! -# init TIM14 for PWM control of the magic LED driver */
|
||||
/*! -# count up to 255 (0 bit resolution) */
|
||||
/*! -# Init TIM14 for PWM control of the magic LED driver */
|
||||
/*! -# Count up to 255 (8 bit resolution) */
|
||||
TIM14->ARR = 0x00FFu;
|
||||
TIM14->CNT = 0u;
|
||||
TIM14->CCR1 = 0u;
|
||||
/*! -# set prescaler to 16 ==> ca. 11 KHz */
|
||||
/*! -# Set prescaler to 16 ==> ca. 11 KHz */
|
||||
TIM14->PSC = 15u;
|
||||
/*! -# PWM Mode 1 + prefetch */
|
||||
TIM14->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE;
|
||||
/*! -# enable Output compare 1 */
|
||||
/*! -# Enable Output compare 1 */
|
||||
TIM14->CCER = TIM_CCER_CC1E;
|
||||
/*! -# finally enable TIM14 */
|
||||
/*! -# Finally, enable TIM14 */
|
||||
TIM14->CR2 = 0;
|
||||
TIM14->CR1 = TIM_CR1_CEN;
|
||||
|
||||
/*! -# set initial state to all 25% */
|
||||
/*! -# Set initial state to all 25% */
|
||||
led_val = 64u;
|
||||
mode = RING_MODE_ALL;
|
||||
mode = RING_MODE_WHITE_DISCRETE;
|
||||
|
||||
temperature_adc_init();
|
||||
|
||||
SysTick_Config(800000);
|
||||
while(1) {
|
||||
temperature = temperature_adc_get_temp();
|
||||
|
||||
/*! -# Gradually dim down the LED brightness in case the temperature is too high */
|
||||
if (temperature > ((MAX_TEMP_CELSIUS) * 10)) {
|
||||
if (led_val > 20)
|
||||
led_val--;
|
||||
}
|
||||
|
||||
led_pwm_val = 0u;
|
||||
switch (mode)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user