summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-12 02:33:32 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2013-07-12 02:33:32 (GMT)
commitffdaa38e67a915dec7e053e39912f57504f8e2c4 (patch)
treec9210eefed1b548fd953afb91d94d932e3b92cd7
parent1caa0e9ec310c14156e2f8239fdd09c939ccac58 (diff)
added spi send - still to long (but only 1 word)
git-svn-id: https://svn.spreadspace.org/pic/trunk@86 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/cmds-16f1847.inc2
-rw-r--r--bootloader/cmds-16f887.inc9
-rw-r--r--bootloader/com-16f887-spi.inc16
3 files changed, 18 insertions, 9 deletions
diff --git a/bootloader/cmds-16f1847.inc b/bootloader/cmds-16f1847.inc
index 67775c5..bed54b9 100644
--- a/bootloader/cmds-16f1847.inc
+++ b/bootloader/cmds-16f1847.inc
@@ -133,7 +133,7 @@ write_flash_segment_next
btfsc EECON1,WRERR
movlw E_FLASH_WERR
movlb .0
- movwf combuff + .2 ; = E_OK
+ movwf combuff + .2 ; = E_OK or write error
movlw .1 ; bytes to send
call send_answer
goto wait_new_cmd
diff --git a/bootloader/cmds-16f887.inc b/bootloader/cmds-16f887.inc
index 5372821..25889c3 100644
--- a/bootloader/cmds-16f887.inc
+++ b/bootloader/cmds-16f887.inc
@@ -99,19 +99,16 @@ write_flash_segment_loop
nop
bcf EECON1,WREN
bcf STATUS,RP0
- incfsz EEADR,f ; increment flash address
- goto write_flash_segment_next
- incf EEADRH,f
-write_flash_segment_next
+ incf EEADR,f ; increment flash address (no need to increment EEADRH -> flash bondaries!)
decfsz cnt,f
goto write_flash_segment_loop
bsf STATUS,RP0
- clrw ; check if a write error occured
+ movlw E_OK ; check if a write error occured
btfsc EECON1,WRERR
movlw E_FLASH_WERR
bcf STATUS,RP1
bcf STATUS,RP0
- movwf combuff + .2 ; = E_OK
+ movwf combuff + .2 ; = E_OK or Write Error
movlw .1 ; bytes to send
call send_answer
goto wait_new_cmd
diff --git a/bootloader/com-16f887-spi.inc b/bootloader/com-16f887-spi.inc
index 7f501cf..e4b8d2a 100644
--- a/bootloader/com-16f887-spi.inc
+++ b/bootloader/com-16f887-spi.inc
@@ -20,10 +20,20 @@
;; along with spreadspace pic utils. If not, see <http://www.gnu.org/licenses/>.
;;
+#define INTPIN PORTA,4
+
;; --- transmit byte and add it to csum
com_tx_byte
- ;; TODO add write
+ movwf SSPBUF
+ bcf INTPIN
xorwf csum,f
+ bsf STATUS,RP0
+com_tx_byte_wait
+ btfss SSPSTAT,BF
+ goto com_tx_byte_wait
+ bcf STATUS,RP0
+ movf SSPBUF,w
+ bsf INTPIN
return
;; ---- wait for byte to be received
@@ -57,8 +67,10 @@ com_init
movlw b'01000000' ; SMP=0,CKE=1
movwf SSPSTAT
bcf TRISC,5 ; RC5(SDO) = out
-
+ bcf INTPIN ; interrupt line to master
+
;; bank 0
bcf STATUS,RP0
movlw b'00100100' ; SSPEN=1,CKP=0,SSPM=0100(SPI Slave with SS)
movwf SSPCON
+ bsf INTPIN