mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Change serial baud to 500k at double-speed; but add cmake option for serial rxmode
This commit is contained in:
+11
-5
@@ -20,9 +20,6 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define USART_BAUD_RATE(BAUD_RATE) \
|
||||
(uint16_t)((float)(F_CPU * 64 / (16 * (float)BAUD_RATE)) + 0.5)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
@@ -31,6 +28,15 @@
|
||||
#include "com232.h"
|
||||
#include "timing.h"
|
||||
|
||||
#if USART_RXMODE == USART_RXMODE_CLK2X_gc
|
||||
#define RXMODE_S 9
|
||||
#elif USART_RXMODE == USART_RXMODE_NORMAL_gc
|
||||
#define RXMODE_S 16
|
||||
#endif
|
||||
|
||||
#define USART_BAUD_RATE(BAUD_RATE) \
|
||||
(uint16_t)((float)(F_CPU * 64 / (USART_RXMODE * (float)BAUD_RATE)) + 0.5)
|
||||
|
||||
uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||
uint8_t readkey;
|
||||
|
||||
@@ -44,11 +50,11 @@ void RS232_Init(void) {
|
||||
|
||||
USART0.CTRLA = USART_RXCIE_bm; // Enable receive interrupts
|
||||
USART0.CTRLB = USART_RXEN_bm | USART_TXEN_bm | // Enable Rx/Tx and set receive
|
||||
USART_RXMODE_NORMAL_gc; // mode normal
|
||||
USART_RXMODE; // mode
|
||||
USART0.CTRLC = USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc |
|
||||
USART_CHSIZE_8BIT_gc |
|
||||
USART_SBMODE_1BIT_gc; // Async UART with 8N1 config
|
||||
USART0.BAUD = USART_BAUD_RATE(250000);
|
||||
USART0.BAUD = USART_BAUD_RATE(500000);
|
||||
}
|
||||
|
||||
ISR(USART0_RXC_vect) {
|
||||
|
||||
Reference in New Issue
Block a user