I emailed Nathan and received a reply, which I will put here. Thanks Nathan!!!
For my own use, I may wrap them up differently and make functions out of them, that either document which registers are used for input/output and are modified and in some cases may have them preserve registers...
Simple HSERIN type function:
Code:
;_HS1_ variables are for uart1 or 2 if only one UART is enabled.
;If both uarts are enables _HS1 variables are for uart1 and _HS2 variables are for uart2
;R2L will hold the next serial byte after executing this function if there is data available
_hserin_wait:
mov.b @_HS1_HSERINEND:16,r0h ;6 Get End address
mov.b @_HS1_HSERINSTART:16,r0l ;6 Get Start address
cmp.b r0h,r0l ;2 If equal we have no data
beq _hserin_nodata:8 ;4
extu.w r0 ;Extend to word
mov.b @(_HS1_HSERINBUF:16,er0),r2l ;Get byte
inc.b r0l ;Inc Start address
and.b #0x7F,r0l ;Incase of overflow force high bit(0-127)
mov.b r0l,@_HS1_HSERINSTART:16 ;Save new Start address
_hserin_nodata:
Simple HSerout function
Code:
;puts value in R0L into buffer to send
_hserout_wait:
mov.b @_HS1_HSEROUTEND:16,r1l ;get end index
mov.b @_HS1_HSEROUTSTART:16,r1h ;get start index
mov.b r1l,r2l ;save copy of _HSEROUTEND
inc.b r1l ;inc _HSEROUTEND
and.b #0x7F,r1l ;limit _HSEROUTEND range
cmp.b r1l,r1h ;If end==start buffer is full so wait until space is available
beq _hserout_wait:8
_ints_save_disable
extu.w r2 ;extend to word
mov.b r0l,@(_HS1_HSEROUTBUF:16,er2) ;put next byte at End address
mov.w #_HS1_SCR3,r3
bclr #7,@er3 ;Disable TIE interrupt
mov.b r1l,@_HS1_HSEROUTEND:16 ;Save new End address
bset #7,@er3 ;Enable TXI interrupt
_ints_restore
Simple HSERVO command
Code:
;hservo example,er5 is rate,er5 is position, er0 is servo pin number
.ifdef _DEFENABLEHSERVO2
and.w #0x1F,r0
add.w #_SERVOTBL,r0 ;calc table data address
mov.b @er0,r0l ;get table data
xor.b r0h,r0h ;isolate servo index
.else
_OUTPUTFUNCMAC ;Set pin to output
.endif
shll.w r0 ;Multiply index by 2
and.w #0x3E,r0 ;limit index
.ifdef _DEF20MHZ
add.w #30000,r4
cmp.w #59999,r4
bls _hservo_cont:8
.else
add.w #24000,r4
cmp.w #47999,r4
bls _hservo_cont:8
.endif
xor.w r4,r4
_hservo_cont:
;if rate = 0 set new POS immediate
mov.w r5,@(_HSERVORATE:16,er0)
bne _hservo_nomove:8
mov.w r4,@(_HSERVOPOS:16,er0)
_hservo_nomove:
;if current POS = 0 set new POS immediate
mov.w @(_HSERVOPOS:16,er0),e4
bne _hservo_nomove2:8
mov.w r4,@(_HSERVOPOS:16,er0)
_hservo_nomove2:
mov.w r4,@(_HSERVONEWPOS:16,er0)
Simple HServoWait function.
Code:
;Example of HSERVOWAIT, er0 holds servo pin number
.ifdef _DEFENABLEHSERVO2
and.w #0x1F,r0
add.w #_SERVOTBL,r0 ;calc table data address
mov.b @er0,r0l ;get table data
xor.b r0h,r0h ;isolate servo index
.endif
shll.w r0 ;Multiply index by 2
and.w #0x3E,r0
mov.w @(_HSERVONEWPOS:16,er0),r1 ;Get NEWPOS
_hservowaitlp:
mov.w @(_HSERVOPOS:16,er0),r2 ;Get current POS
cmp.w r1,r2
bne _hservowaitlp:8
From these code extracts we should also create several of the other functions as well, such as HSERVOPOS and HSERVOIDLE.
Thanks again!
Kurt