From: ceb Date: Thu, 3 Nov 2005 00:40:57 +0000 (+0000) Subject: comments/structure for detection X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=2b79b5d2b01e1ae0a242fbc22b297ad049574884;p=trains.git comments/structure for detection --- diff --git a/detpic/detect.asm b/detpic/detect.asm index 822c6f8..b3911e2 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -20,6 +20,109 @@ code +;**************************************************************************** +; needs conditional for master + +; MASTER PIC +; triggered whenever there is space in the serial buffer + +; reads detection data from subpics over i2c and sends new data out to +; external computer + + + + + +; Associated registers etc.: +; subpic s ? bits current subpic for dtction data retrieval +; Psa-e 40 registers current state of detection data from +; ports a-e of all subpics (including self) +; Csa-e 40 registers current state of knowledge of +; external computer +; ??? ??? bits for keeping track of subpic # +; ??? ??? bits for keeping track of detect msg creation +; and posn in Psa-e checking +; Ma-e 5 bytes bitmask for reading detect data from ports + + + +; ask sub-pic s for data +; (i.e. send i2c request - will need to work out how to differentiate this +; from requests fior other data from subpics, or make a general routine to +; handle all sorts of data a subpic might send back) + +; if no change, advance subpic # and return + +; if change, copy data from subpic x into xa-e + +; compare Psa-e with Csa-e + +; if no change, advance subpic # and return + +; if change, for each different bit, create detect msg & send to serial buffer +; also flip state of bit in C + +; advance subpic # and return + + +; NB for self, can skip i2c and just read straight from legs according to +; bitmask Ma-e + +; will need to use external routines for: i2c, serial_send + + + + +;**************************************************************************** +; needs conditional for slave + +; SLAVE PIC +; main loop of slave program + +; Reads from detection legs as defined by bitmasks Ma-e applied to ports a-e. +; Writes the result into registers Pa-e. On i2c interrupt, checks that there +; is new data to send to the master pic and if so sends it. Current state of +; master's knowledge is stored in Ca-e for comparison with Pa-e. +; +; Associated registers etc.: +; Pa-e 5 registers data from detection legs +; Ma-e 5 registers bitmask defining detction legs +; Ca-e 5 registers current state of data held in master +; for this slave pic +; ??? 1 bit 'something to send' y/n +; ??? ? bits 'currently reading from port' 1-5 (=a-e) + +; disable interrupts + +; read data from detection legs associated with current port + +; invert bits; OR with Pn; AND with Mn; store in Pn + +; compare Pn and Cn; if different, set 'something to send' + +; enable interrupts + +; advance port # + +; on i2c interrupt: +; check 'something to send' +; if=0, send 'no change' (precise message = ?) +; if=1, clear 'something to send'; copy Pa-e -> Ca-e; blank Pa-e; write Ca-e +; to i2c output buffer; start sending (check whether this will be sent +; automatically or whether I will need to pay it attention); +; return + +; will need to use external i2c send function/buffers, maybe? + + + + + + + + + + ;**************************************************************************** vector_reset