Loading include/arch/msp430fr5969lp/driver/stdin1.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright 2020 Birte Kristina Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #ifndef STANDARDINPUT1_H #define STANDARDINPUT1_H class StandardInput1 { private: StandardInput1(const StandardInput1 ©); static unsigned char const bufsize = 32; char buffer[bufsize]; volatile unsigned char write_pos; unsigned char read_pos; public: StandardInput1() : write_pos(0), read_pos(0) {} void setup(); bool hasKey(); char getKey(); inline void addKey(char key) { buffer[write_pos++] = key; write_pos %= bufsize; } }; extern StandardInput1 kin1; #endif src/arch/msp430fr5969lp/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ help RX: P2.1 (eUSCI_A0 / UCA0RXD) select meta_driver_stdin config arch_msp430fr5969lp_driver_stdin1 bool "UART Input on eUSCI_A1 / P2.6" help RX: P2.6 (eUSCI_A1 / UCA1RXD) depends on arch_msp430fr5969lp_driver_stdout1 select meta_driver_stdin1 config arch_msp430fr5969lp_driver_timer bool "Timer with Interrupts" select meta_driver_timer Loading src/arch/msp430fr5969lp/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ ifdef CONFIG_arch_msp430fr5969lp_driver_stdin CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdin.cc endif ifdef CONFIG_arch_msp430fr5969lp_driver_stdin1 CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdin1.cc endif ifdef CONFIG_arch_msp430fr5969lp_driver_i2c CXX_TARGETS += src/arch/msp430fr5969lp/driver/i2c.cc COMMON_FLAGS += -DDRIVER_I2C Loading src/arch/msp430fr5969lp/driver/stdin1.cc 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 2020 Birte Kristina Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #include "driver/stdin1.h" #include <msp430.h> void StandardInput1::setup() { UCA1CTLW0 |= UCSWRST; P2SEL0 &= ~BIT6; P2SEL1 |= BIT6; UCA1CTLW0 &= ~UCSWRST; UCA1IE |= UCRXIE; } bool StandardInput1::hasKey() { if (write_pos != read_pos) { return true; } return false; } char StandardInput1::getKey() { char ret = buffer[read_pos++]; read_pos %= bufsize; return ret; } StandardInput1 kin1; __attribute__((interrupt(USCI_A1_VECTOR))) __attribute__((wakeup)) void handle_stdin1() { if (UCA1IFG & UCRXIFG) { kin1.addKey(UCA1RXBUF); } } Loading
include/arch/msp430fr5969lp/driver/stdin1.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright 2020 Birte Kristina Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #ifndef STANDARDINPUT1_H #define STANDARDINPUT1_H class StandardInput1 { private: StandardInput1(const StandardInput1 ©); static unsigned char const bufsize = 32; char buffer[bufsize]; volatile unsigned char write_pos; unsigned char read_pos; public: StandardInput1() : write_pos(0), read_pos(0) {} void setup(); bool hasKey(); char getKey(); inline void addKey(char key) { buffer[write_pos++] = key; write_pos %= bufsize; } }; extern StandardInput1 kin1; #endif
src/arch/msp430fr5969lp/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ help RX: P2.1 (eUSCI_A0 / UCA0RXD) select meta_driver_stdin config arch_msp430fr5969lp_driver_stdin1 bool "UART Input on eUSCI_A1 / P2.6" help RX: P2.6 (eUSCI_A1 / UCA1RXD) depends on arch_msp430fr5969lp_driver_stdout1 select meta_driver_stdin1 config arch_msp430fr5969lp_driver_timer bool "Timer with Interrupts" select meta_driver_timer Loading
src/arch/msp430fr5969lp/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ ifdef CONFIG_arch_msp430fr5969lp_driver_stdin CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdin.cc endif ifdef CONFIG_arch_msp430fr5969lp_driver_stdin1 CXX_TARGETS += src/arch/msp430fr5969lp/driver/stdin1.cc endif ifdef CONFIG_arch_msp430fr5969lp_driver_i2c CXX_TARGETS += src/arch/msp430fr5969lp/driver/i2c.cc COMMON_FLAGS += -DDRIVER_I2C Loading
src/arch/msp430fr5969lp/driver/stdin1.cc 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 2020 Birte Kristina Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #include "driver/stdin1.h" #include <msp430.h> void StandardInput1::setup() { UCA1CTLW0 |= UCSWRST; P2SEL0 &= ~BIT6; P2SEL1 |= BIT6; UCA1CTLW0 &= ~UCSWRST; UCA1IE |= UCRXIE; } bool StandardInput1::hasKey() { if (write_pos != read_pos) { return true; } return false; } char StandardInput1::getKey() { char ret = buffer[read_pos++]; read_pos %= bufsize; return ret; } StandardInput1 kin1; __attribute__((interrupt(USCI_A1_VECTOR))) __attribute__((wakeup)) void handle_stdin1() { if (UCA1IFG & UCRXIFG) { kin1.addKey(UCA1RXBUF); } }