;=============================================================================== ; SPLat Controls. ; ; Product Development Group ; ; Melbourne, AUSTRALIA ; ;=============================================================================== ;PURPOSE: ; SEXI application for a UI420. Maps all the UI420 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 ;=============================================================================== ; ; ;RAM storage ; ;=============================================================================== ;=============================================================================== ; ; ;I/O Assignments ; ;=============================================================================== ;-- digital inputs -- iPot0 EQU 0 iPot1 EQU 1 iBtn0 EQU 2 iBtn1 EQU 3 iBtn2 EQU 4 iBtn3 EQU 5 ;-- digital outputs -- oLED0On EQU 0 oLED0Green EQU 1 oLED1On EQU 2 oLED1Green EQU 3 oLED2On EQU 4 oLED2Green EQU 5 oLED3On EQU 6 oLED3Green EQU 7 oBuzzer EQU 8 oBacklight EQU 9 ;-- analogue inputs -- ;-- analogue outputs -- ;-- serial -- ;=============================================================================== ; ;AUTOMATIC RAM ; ;=============================================================================== ; ; ; ; ; ; XWkInputLen #EQU 3 XWabInputBuffer defBLOCK XWkInputLen XWbInputSeq defBYTE XWbInputs0_7 defBYTE XWbInputK0_7 defBYTE 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: LoadX 0 ;set I/O board address XwireSetAddr XwireSlave XWStab ;start Xwire LaunchTask XWIOTask 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: LoadX 0 ;signal we have.. LoadX %11111111 OutputM 0 On oLED0On ;..no connection OBLCD_Dim 0,5,3 SetMem XWbInputSeq,0 ;setup start up synchronisation SetMem XWbInputSeqEcho,255 _XWIOWafFirstPacket YieldTask GoIfMz XWbInputSeqEcho,_XWIOGotConnection ;wait for masters first output update Goto _XWIOWafFirstPacket _XWIOGotConnection On oLED0Green ;signal we are now connected OBLCD_Dim 0,5,3 _XWIOSendInputs LoadX %11111111 ;capture rising edge flags InputMK 0 Store XWbInputK0_7 InputM 0 ;capture debounced input levels Store XWbInputs0_7 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