MODSERIAL with support for more devices + f767

Files at this revision

API Documentation at this revision

Comitter:
dimavb
Date:
Mon Sep 30 16:23:18 2019 +0000
Parent:
46:d2a5e26fd658
Commit message:
add f767

Changed in this revision

Device/MODSERIAL_NUCLEO_F767ZI.cpp Show annotated file Show diff for this revision Revisions of this file
Device/MODSERIAL_NUCLEO_F767ZI.h Show annotated file Show diff for this revision Revisions of this file
MACROS.h Show annotated file Show diff for this revision Revisions of this file
diff -r d2a5e26fd658 -r 5c21920f187e Device/MODSERIAL_NUCLEO_F767ZI.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Device/MODSERIAL_NUCLEO_F767ZI.cpp	Mon Sep 30 16:23:18 2019 +0000
@@ -0,0 +1,25 @@
+#ifdef TARGET_NUCLEO_F767ZI
+#include "MODSERIAL.h"
+
+void MODSERIAL::setBase(void ) {
+#if DEVICE_SERIAL_ASYNCH
+switch( _serial.serial.index ) {
+#else
+switch( _serial.index ) {
+#endif
+        case 0: _base = USART1; _IRQ = USART1_IRQn; break;
+        case 1: _base = USART2; _IRQ = USART2_IRQn; break;
+        case 2: _base = USART3; _IRQ = USART3_IRQn; break;
+        case 3: _base = USART6; _IRQ = USART6_IRQn; break;
+        default: _base = NULL; _IRQ = (IRQn_Type)NULL; break;
+    }
+}
+
+void MODSERIAL::initDevice(void) {};
+
+bool MODSERIAL::txIsBusy( void )
+{
+    return ( (((USART_TypeDef*)_base)->ISR & ( 1UL << 6 )) == 0 ) ? true : false;
+}
+
+#endif
diff -r d2a5e26fd658 -r 5c21920f187e Device/MODSERIAL_NUCLEO_F767ZI.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Device/MODSERIAL_NUCLEO_F767ZI.h	Mon Sep 30 16:23:18 2019 +0000
@@ -0,0 +1,20 @@
+#if defined(TARGET_NUCLEO_F767ZI)
+
+
+#define MODSERIAL_IRQ_REG ((USART_TypeDef*)_base)->CR1  //found in mbed-dev\targets\TARGET_STM\TARGET_STM32F7\TARGET_STM32F746xG\device\stm32f746xx.h
+#define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_TXEIE
+#define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_RXNEIE
+#define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_TXEIE
+#define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_RXNEIE
+
+#define MODSERIAL_READ_REG ((USART_TypeDef*)_base)->RDR
+#define MODSERIAL_WRITE_REG ((USART_TypeDef*)_base)->TDR
+#define MODSERIAL_READABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_RXNE) != 0)
+#define MODSERIAL_WRITABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_TXE) != 0)
+
+#define RESET_TX_FIFO while(0 == 1)
+#define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG
+
+#define RX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_RXNEIE) != 0)
+#define TX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_TXEIE) != 0)
+#endif
diff -r d2a5e26fd658 -r 5c21920f187e MACROS.h
--- a/MACROS.h	Sun May 05 14:57:11 2019 +0000
+++ b/MACROS.h	Mon Sep 30 16:23:18 2019 +0000
@@ -32,6 +32,7 @@
 #include "MODSERIAL_PAC_F401RB.h"
 #include "MODSERIAL_NUCLEO_F103RB.h"
 #include "MODSERIAL_NUCLEO_F746ZG.h"
+#include "MODSERIAL_NUCLEO_F767ZI.h"
 
 #define MODSERIAL_TX_BUFFER_EMPTY (buffer_count[TxIrq]==0)
 #define MODSERIAL_RX_BUFFER_EMPTY (buffer_count[RxIrq]==0)