jmlprop
02-05-2007, 04:46 AM
Hello All,
I am new to the prop and trying to understand the code associated with serial data transfer. It is my assumption that the code below declares some varibles along with transmit & recieve buffers. Public method "Start" accepts these parameters passed to it
to set up the baud rate, mode,·ect., checks to see if a cog has started and returns its boolean value.
·Am I on track so far ?
·I need to understand this process fully for a project that I am working on.
·If so, could someone please explain the following lines of code more detail.
··stop
· longfill(@rx_head, 0, 4)
· longmove(@rx_pin, @rxpin, 3)
· bit_ticks := clkfreq / baudrate
· buffer_ptr := @rx_buffer
· okay := cog := cognew(@entry, @rx_head) + 1
''************************************
''*· Full-Duplex Serial Driver v1.1· *
''*· (C) 2006 Parallax, Inc.········ *
''************************************
VAR
· long· cog···················· 'cog flag/id
· long· rx_head················ '9 contiguous longs
· long· rx_tail
· long· tx_head
· long· tx_tail
· long· rx_pin
· long· tx_pin
· long· rxtx_mode
· long· bit_ticks
· long· buffer_ptr
····················
· byte· rx_buffer[16]
· byte· tx_buffer[16]·
PUB start(rxpin, txpin, mode, baudrate) : okay
'' mode bit 0 = invert rx
'' mode bit 1 = invert tx
'' mode bit 2 = open-drain/source tx
'' mode bit 3 = ignore tx echo on rx
· stop
· longfill(@rx_head, 0, 4)
· longmove(@rx_pin, @rxpin, 3)
· bit_ticks := clkfreq / baudrate
· buffer_ptr := @rx_buffer
· okay := cog := cognew(@entry, @rx_head) + 1
·
I am new to the prop and trying to understand the code associated with serial data transfer. It is my assumption that the code below declares some varibles along with transmit & recieve buffers. Public method "Start" accepts these parameters passed to it
to set up the baud rate, mode,·ect., checks to see if a cog has started and returns its boolean value.
·Am I on track so far ?
·I need to understand this process fully for a project that I am working on.
·If so, could someone please explain the following lines of code more detail.
··stop
· longfill(@rx_head, 0, 4)
· longmove(@rx_pin, @rxpin, 3)
· bit_ticks := clkfreq / baudrate
· buffer_ptr := @rx_buffer
· okay := cog := cognew(@entry, @rx_head) + 1
''************************************
''*· Full-Duplex Serial Driver v1.1· *
''*· (C) 2006 Parallax, Inc.········ *
''************************************
VAR
· long· cog···················· 'cog flag/id
· long· rx_head················ '9 contiguous longs
· long· rx_tail
· long· tx_head
· long· tx_tail
· long· rx_pin
· long· tx_pin
· long· rxtx_mode
· long· bit_ticks
· long· buffer_ptr
····················
· byte· rx_buffer[16]
· byte· tx_buffer[16]·
PUB start(rxpin, txpin, mode, baudrate) : okay
'' mode bit 0 = invert rx
'' mode bit 1 = invert tx
'' mode bit 2 = open-drain/source tx
'' mode bit 3 = ignore tx echo on rx
· stop
· longfill(@rx_head, 0, 4)
· longmove(@rx_pin, @rxpin, 3)
· bit_ticks := clkfreq / baudrate
· buffer_ptr := @rx_buffer
· okay := cog := cognew(@entry, @rx_head) + 1
·