;=============================================================================== ; SPLat Controls. ; ; Product Development Group ; ; Melbourne, AUSTRALIA ; ;=============================================================================== ;PURPOSE: ; SEXI application for a CC18. Maps all the CC18 I/O into the SEXI address ; space. ; ;=============================================================================== ;=============================================================================== ; Copyright (c) 2015 SPLat Controls. All rights reserved. ; ; ; ; THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SPLat Controls. ; ; The copyright notice above does not evidence any ; ; actual or intended publication of such source code. ; ;=============================================================================== ;=============================================================================== ; ; ; ;=============================================================================== GoSub XWIOsubInitialise RunTasksForever ;=============================================================================== ; ; ; ;=============================================================================== ;maximum time between Xwire data transfers (sEQUence number changes) before we ;turn off all outputs and return to the synchronisation phase (10ms increments) XWkErrorTime EQU 30 ;LED Colours LEDkOff EQU 0 LEDkGreen EQU 1 LEDkRed EQU 2 LEDkOrange EQU 3 LEDkRedGreen EQU 4 LEDkBlinkGreen EQU 5 LEDkBlinkRed EQU 6 LEDkBlinkOrange EQU 7 ;=============================================================================== ; ; ;RAM storage ; ;=============================================================================== ;=============================================================================== ; ; ;I/O Assignments ; ;=============================================================================== ;-- digital inputs -- ;-- digital outputs -- ;-- analogue inputs -- ;-- analogue outputs -- ;-- serial -- ;=============================================================================== ; ;AUTOMATIC RAM ; ;=============================================================================== ; ; ; ; ; ; XWkInputLen #EQU 13 XWabInputBuffer defBLOCK XWkInputLen XWbInputSeq defBYTE XWbInputs0_7 defBYTE XWbInputs8_15 defBYTE XWbInputK0_7 defBYTE XWbInputK8_15 defBYTE XWfAnalogIn0 defFLOAT XWfAnalogIn1 defFLOAT XWkOutputLen #EQU 5 XWabOutputBuffer defBLOCK XWkOutputLen XWbInputSeqEcho defBYTE XWbOutput0_7 defBYTE XWbOutput8_15 defBYTE XWbBlink0_7 defBYTE XWbBlink8_15 defBYTE ;=============================================================================== ; ; ; ;=============================================================================== ;=============================================================================== ;DESCRIPTION: ; Initialises the SEXI slave task at power-on ;PARAMETERS: ; -> ;RETURNS: ; <- ;=============================================================================== XWIOsubInitialise: XwireGetJumpers ;set I/O board address from jumpers (0,1,2 or 3) XwireSetAddr XwireSlave XWStab ;start Xwire LaunchTask XWIOTask ;CC18 I/O processing task Return ;=============================================================================== ;DESCRIPTION: ; This task sends level and edge input data to the Xwire master. A sequence ; number is used to ensure the input data to the Xwire master is only updated ; once the master has acknowledge receipt of the last data set. During ; operation, the slave increments the sequence number and then waits for the ; return sequence number from the master to be equal before reading the lastest ; input data. ;=============================================================================== XWIOTask: SetU 0,LEDkRed ;signal we have.. SPxCmd1 2,!CPU ;..no connection SetMem XWbInputSeq,0 ;setup start up synchronisation SetMem XWbInputSeqEcho,255 _XWIOWafFirstPacket YieldTask GoIfMz XWbInputSeqEcho,_XWIOGotConnection ;wait for masters first output update Goto _XWIOWafFirstPacket _XWIOGotConnection SetU 0,LEDkGreen ;signal we are now.. SPxCmd1 2,!CPU ;..connected _XWIOSendInputs LoadX %11111111 ;capture rising edge flags InputMK 0 Store XWbInputK0_7 LoadX %11111111 InputMK 8 Store XWbInputK8_15 InputM 0 ;capture debounced input levels Store XWbInputs0_7 InputM 8 Store XWbInputs8_15 fAnIn 0 ;pass latest analogue values to the master fStore XWfAnalogIn0 fAnIn 1 fStore XWfAnalogIn1 Recall XWbInputSeq ;increment the sEQUence number but avoid zero IncX Push GoIfnz _XWIOStoreSeq IncX _XWIOStoreSeq Store XWbInputSeq MarkTime _XWIOWafNewPacket YieldTask Recall XWbInputSeq ;wait for master to echo our sEQUence number back to us Recall XWbInputSeqEcho Compare GoIfz _XWIOHandleNewPacket LoopIfTiming XWkErrorTime,_XWIOWafNewPacket ;check for Xwire communication error LoadX 0 ;Xwire communications lost, turn off all outputs LoadX %11111111 OutputM 0 ;digital 0 thru 7 LoadX 0 LoadX %11111111 OutputM 8 ;digital 8 thru 15 Goto XWIOTask ;re-synchronise _XWIOHandleNewPacket Recall XWbOutput0_7 ;update outputs if not being blinked Recall XWbBlink0_7 NotM OutputM 0 Recall XWbOutput8_15 Recall XWbBlink8_15 NotM OutputM 8 Recall XWbBlink0_7 ;update blink outputs BlinkM 0 Recall XWbBlink8_15 BlinkM 8 Goto _XWIOSendInputs ;=============================================================================== ; ; ; ;=============================================================================== ;=============================================================================== ; ; ; ;=============================================================================== ;=============================================================================== ; ; ; ;=============================================================================== NVEM0 ;Start of non-volatile memory ;=============================================================================== ; ; ;Non-volatile memory data ; ;=============================================================================== XWStab NV0Byte XWabInputBuffer,XWkInputlen,XWabOutputBuffer,XWkOutputLen