Professional Documents
Culture Documents
h"
extern unsigned int count;
void switch_redLED_off(void);
void switch_redLED_on(void);
void switch_blueLED_off(void);
void switch_blueLED_on(void);
void switch_greenLED_off(void);
void switch_greenLED_on(void);
uint32_t SW_UP(void);//JOystick
uint32_t SW_CENTER(void);
uint32_t SW_DOWN(void);
void flashing_red(void);
void delay_ms(uint32_t t);
void SystemClock_Config(void);
int main(void){
SystemClock_Config();
while (1){
if(SW_UP())
flashing_red();
else
switch_redLED_off();
if(SW_CENTER())
switch_blueLED_on();
else
switch_blueLED_off();
if(SW_DOWN())
switch_greenLED_on();
else
switch_greenLED_off();
}
}
uint32_t SW_UP(void) {
void switch_redLED_off(void) {
void switch_redLED_on(void) {
void switch_blueLED_on(void) {
void switch_greenLED_on(void) {
void flashing_red(void){
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_4);
delay_ms(200);
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_4);
delay_ms(200);
}
uint32_t millis(void) {
return count;
}
void delay_ms(uint32_t t) {
uint32_t start, end;
start = millis();
end = start + t;
if (start < end) {
while ((millis() >= start) && (millis() < end)) {
// do nothing
}
} else {
while ((millis() >= start) || (millis() < end)) {
// do nothing
};
}
}
/**
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 84000000
* HCLK(Hz) = 84000000
* AHB Prescaler = 1
* APB1 Prescaler = 1
* APB2 Prescaler = 2
* HSE Frequency(Hz) = 8000000
* PLL_M = 8
* PLL_N = 336
* PLL_P = 4
* VDD(V) = 3.3
* Main regulator output voltage = Scale2 mode
* Flash Latency(WS) = 2
*/
void SystemClock_Config(void)
{
/* Enable HSE oscillator */
LL_RCC_HSE_EnableBypass();
LL_RCC_HSE_Enable();
while(LL_RCC_HSE_IsReady() != 1)
{
};