static void gpio_setup(void)
{
+ // PC13 = BluePill LED
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);
+ gpio_clear(GPIOC, GPIO13);
+
+ // PC14 = bypass LED*
+ gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO14);
+ gpio_set(GPIOC, GPIO14);
+
+ // PC15 = bypass opto-coupler
+ gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO15);
+ gpio_clear(GPIOC, GPIO15);
}
static volatile u32 ms_ticks;
usart_set_baudrate(USART1, 115200);
usart_set_databits(USART1, 8);
usart_set_stopbits(USART1, USART_STOPBITS_1);
- usart_set_mode(USART1, USART_MODE_TX);
+ usart_set_mode(USART1, USART_MODE_TX_RX);
usart_set_parity(USART1, USART_PARITY_NONE);
usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE);
usart_enable(USART1);
}
+static bool bypass_active;
+
static void show_temperature(void)
{
debug_putc('#');
else
debug_printf("%3d.%03d", t / 1000, t % 1000);
}
+ debug_putc(' ');
+ debug_putc('0' + bypass_active);
debug_puts("\r\n");
}
gpio_toggle(GPIOC, GPIO13);
delay_ms(100);
ds_step();
+ if (usart_get_flag(USART1, USART_SR_RXNE)) {
+ uint ch = usart_recv(USART1);
+ if (ch == 'B') {
+ bypass_active = 1;
+ gpio_set(GPIOC, GPIO15); // opto-coupler
+ gpio_clear(GPIOC, GPIO14); // LED
+ } else if (ch == 'b') {
+ bypass_active = 0;
+ gpio_clear(GPIOC, GPIO15); // opto-coupler
+ gpio_set(GPIOC, GPIO14); // LED
+ }
+ }
if (cycles++ >= 50) {
cycles = 0;
show_temperature();