Revision: 1459
Author: jsuijs
Date: Wed Nov 4 14:19:03 2009
Log: support for one stopbit.
http://code.google.com/p/jallib/source/detail?r=1459
Modified:
/trunk/include/peripheral/usart/serial_software.jal
=======================================
--- /trunk/include/peripheral/usart/serial_software.jal Mon Sep 28 12:28:10
2009
+++ /trunk/include/peripheral/usart/serial_software.jal Wed Nov 4 14:19:03
2009
@@ -14,8 +14,9 @@
-- for lower Xtal frequencies the maximum baudrate will be equally lower.
-- Baudrates are optimized, so even the high baudrates shouldn't be a
problem
-- (my [Stef] standard = 115_200 Baud, which has never given me any
problems).
--- Interrupts should be disabled during transmissions.
+-- Interrupts are disabled during transmissions.
-- Transmission parameters are 8 databits, 2 stopbits, no parity, no
handshake.
+-- const serial_sw_stopbits = 1 ; setup for one stopbit.
--
-- TODO: should transmission parameters be configurable ?
-- (8 databits, 1 stopbits, no parity, no handshake)
@@ -26,6 +27,11 @@
const bit serial_sw_invert = true
end if
+if (defined(serial_sw_stopbits) == false) then
+ -- default is 2 stopbits
+ const serial_sw_stopbits = 2
+end if
+
procedure serial_sw_init() is
-- ouput/tx pin active or not according to invert
if serial_sw_invert then
@@ -167,9 +173,9 @@
data = data >> 1
_usec_delay((1_000_000/serial_sw_baudrate)-2)
end loop
- -- add 2 stop bits
+ -- add stop bit(s)
serial_sw_tx_pin = high
- _usec_delay((2_000_000/serial_sw_baudrate))
+ _usec_delay((serial_sw_stopbits * (1_000_000/serial_sw_baudrate)))
else
-- invert the data
@@ -182,12 +188,9 @@
data = data >> 1
_usec_delay((1_000_000/serial_sw_baudrate)-2)
end loop
- -- add 1st stop bits
+ -- add stop bit(s)
serial_sw_tx_pin = low
- _usec_delay((1_000_000/serial_sw_baudrate))
- ;-- add 2nd stop bits
- ;serial_sw_tx_pin = low
- ;_usec_delay((1_000_000/serial_sw_baudrate))
+ _usec_delay((serial_sw_stopbits * (1_000_000/serial_sw_baudrate)))
end if
-- restore old interrupt status
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---