You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.7 KiB
73 lines
1.7 KiB
/*
|
|
* application.c
|
|
*
|
|
* Created on: Jan 30, 2022
|
|
* Author: ftobler
|
|
*/
|
|
|
|
#include "application.h"
|
|
#include "stdint.h"
|
|
#include "main.h"
|
|
#include "gpio.h"
|
|
#include "serial.h"
|
|
|
|
|
|
Serial serialUSB;
|
|
Serial serialRS485;
|
|
|
|
void setup() {
|
|
Serial_init(&serialUSB, &huart1);
|
|
Serial_init(&serialRS485, &huart2);
|
|
//gpio_SetPin(UART2_FLOW_GPIO_Port, UART2_FLOW_Pin);
|
|
Serial_initFlow(&serialRS485, UART2_FLOW_GPIO_Port, UART2_FLOW_Pin);
|
|
}
|
|
|
|
|
|
void loop() {
|
|
while (Serial_available(&serialRS485)) {
|
|
uint8_t b = Serial_read(&serialRS485);
|
|
Serial_write(&serialUSB, b);
|
|
}
|
|
while (Serial_available(&serialUSB)) {
|
|
uint8_t b = Serial_read(&serialUSB);
|
|
Serial_write(&serialRS485, b);
|
|
}
|
|
}
|
|
|
|
|
|
uint32_t counter = 0;
|
|
uint32_t mode = 0;
|
|
|
|
void systick() {
|
|
counter++;
|
|
if (counter >= 250) {
|
|
counter = 0;
|
|
mode = (mode + 1) % 4;
|
|
switch (mode) {
|
|
case 0:
|
|
gpio_SetPin(LED0_GPIO_Port, LED0_Pin);
|
|
gpio_ResetPin(LED1_GPIO_Port, LED1_Pin);
|
|
gpio_ResetPin(LED2_GPIO_Port, LED2_Pin);
|
|
gpio_ResetPin(LED3_GPIO_Port, LED3_Pin);
|
|
break;
|
|
case 1:
|
|
gpio_ResetPin(LED0_GPIO_Port, LED0_Pin);
|
|
gpio_SetPin(LED1_GPIO_Port, LED1_Pin);
|
|
gpio_ResetPin(LED2_GPIO_Port, LED2_Pin);
|
|
gpio_ResetPin(LED3_GPIO_Port, LED3_Pin);
|
|
break;
|
|
case 2:
|
|
gpio_ResetPin(LED0_GPIO_Port, LED0_Pin);
|
|
gpio_ResetPin(LED1_GPIO_Port, LED1_Pin);
|
|
gpio_SetPin(LED2_GPIO_Port, LED2_Pin);
|
|
gpio_ResetPin(LED3_GPIO_Port, LED3_Pin);
|
|
break;
|
|
case 3:
|
|
gpio_ResetPin(LED0_GPIO_Port, LED0_Pin);
|
|
gpio_ResetPin(LED1_GPIO_Port, LED1_Pin);
|
|
gpio_ResetPin(LED2_GPIO_Port, LED2_Pin);
|
|
gpio_SetPin(LED3_GPIO_Port, LED3_Pin);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|