(HACK): virtual: initial implementation

wip/virtual-tbm
Merlijn Wajer 5 years ago
parent 4b49f643ca
commit b9580b17fd
  1. 4
      include/buzzer.h
  2. 2
      include/console.h
  3. 2
      include/led.h
  4. 1
      include/rtc.h
  5. 1
      source/main.c
  6. 18
      source/platform/usart.c
  7. 2
      source/shell/alarm.c
  8. 1
      source/shell/buzzer.c
  9. 2
      source/shell/led.c

@ -1,10 +1,14 @@
#pragma once #pragma once
/*
#include <libopencm3/stm32/timer.h> #include <libopencm3/stm32/timer.h>
*/
struct buzzer { struct buzzer {
uint32_t timer; uint32_t timer;
/*
enum tim_oc_id channel; enum tim_oc_id channel;
*/
}; };
void buzzer_init(struct buzzer *buzzer); void buzzer_init(struct buzzer *buzzer);

@ -1,6 +1,8 @@
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#if HAVE_SYS_TYPES_H #if HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <stdint.h>
struct led { struct led {
uint32_t port; uint32_t port;
uint32_t pin; uint32_t pin;

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <time.h> #include <time.h>
#include <stdint.h>
#define SECS_PER_DAY (24 * 60 * 60) #define SECS_PER_DAY (24 * 60 * 60)

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <buzzer.h> #include <buzzer.h>
#include <console.h> #include <console.h>

@ -1,7 +1,11 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdint.h>
/*
#include <libopencm3/stm32/usart.h> #include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h> #include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/scb.h> #include <libopencm3/cm3/scb.h>
*/
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -30,6 +34,7 @@ struct usart_console {
static struct usart_console usart[2]; static struct usart_console usart[2];
#if 0
#ifdef STM32F0 #ifdef STM32F0
#define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT #define USART_STOPBITS_1 USART_CR2_STOP_1_0BIT
#endif #endif
@ -37,9 +42,15 @@ static struct usart_console usart[2];
#ifdef STM32F1 #ifdef STM32F1
#define USART_ISR_RXNE USART_SR_RXNE #define USART_ISR_RXNE USART_SR_RXNE
#endif #endif
#endif
void usart_send_blocking(uint32_t dev, char c) {
return;
}
static void usart_isr(struct usart_console *console) static void usart_isr(struct usart_console *console)
{ {
#if 0
size_t i; size_t i;
if (!console) if (!console)
@ -53,6 +64,7 @@ static void usart_isr(struct usart_console *console)
if (i != console->cur) if (i != console->cur)
console->next = i; console->next = i;
} }
#endif
} }
void usart1_isr(void) void usart1_isr(void)
@ -192,17 +204,20 @@ static int usart_get_irq_no(unsigned *irq_no, unsigned dev)
if (!irq_no) if (!irq_no)
return -1; return -1;
#if 0
switch (dev) { switch (dev) {
case USART1: *irq_no = NVIC_USART1_IRQ; break; case USART1: *irq_no = NVIC_USART1_IRQ; break;
case USART2: *irq_no = NVIC_USART2_IRQ; break; case USART2: *irq_no = NVIC_USART2_IRQ; break;
default: return -1; default: return -1;
} }
#endif
return 0; return 0;
} }
static int usart_init(struct usart_console *console) static int usart_init(struct usart_console *console)
{ {
#if 0
if (usart_get_irq_no(&console->irq_no, console->dev) < 0) if (usart_get_irq_no(&console->irq_no, console->dev) < 0)
return -1; return -1;
@ -216,6 +231,7 @@ static int usart_init(struct usart_console *console)
nvic_enable_irq(console->irq_no); nvic_enable_irq(console->irq_no);
usart_enable(console->dev); usart_enable(console->dev);
usart_enable_rx_interrupt(console->dev); usart_enable_rx_interrupt(console->dev);
#endif
return 0; return 0;
} }
@ -232,11 +248,13 @@ struct console *console_init(unsigned dev_id)
console = usart + dev_id; console = usart + dev_id;
#if 0
switch (dev_id) { switch (dev_id) {
case 0: console->dev = USART1; break; case 0: console->dev = USART1; break;
case 1: console->dev = USART2; break; case 1: console->dev = USART2; break;
default: return NULL; default: return NULL;
} }
#endif
console->cur = 0; console->cur = 0;
console->next = 0; console->next = 0;

@ -2,7 +2,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if 0
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#endif
#include <console.h> #include <console.h>
#include <rtc.h> #include <rtc.h>

@ -1,6 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <buzzer.h> #include <buzzer.h>
#include <console.h> #include <console.h>

@ -2,7 +2,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if 0
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#endif
#include <console.h> #include <console.h>
#include <led.h> #include <led.h>

Loading…
Cancel
Save