diff options
author | Christian Pointner <equinox@mur.at> | 2012-07-05 02:17:12 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2012-07-05 02:17:12 +0000 |
commit | 295c08fbc04e5c6e62d64be6053718d8c759c209 (patch) | |
tree | 993e3878284cb84c3c31a44db9fa472f10cd2f79 /software | |
parent | battmon with gnd contacts (diff) |
ssp test works
git-svn-id: https://svn.spreadspace.org/mur.sat@576 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r-- | software/idm-test/idm-test.c | 18 | ||||
-rw-r--r-- | software/idm/idm.asm | 47 |
2 files changed, 47 insertions, 18 deletions
diff --git a/software/idm-test/idm-test.c b/software/idm-test/idm-test.c index 49fe3fc..a4c4535 100644 --- a/software/idm-test/idm-test.c +++ b/software/idm-test/idm-test.c @@ -127,8 +127,20 @@ void IDM_SendCmd(uint8_t cmd) led_off();
}
+unsigned char tmp_cnt = 0;
+
void IDM_ReadData(void)
{
+ /* uint8_t int_state = (INT_PIN & (1<<INT)); */
+ /* while(!int_state) { */
+ /* RingBuffer_Insert(&SPItoUSB_Buffer, tmp_cnt); */
+ /* /\* tmp_cnt = tmp_cnt >= 255 ? 32 : tmp_cnt+1; *\/ */
+ /* tmp_cnt++; */
+ /* if(RingBuffer_IsFull(&SPItoUSB_Buffer)) */
+ /* break; */
+ /* int_state = (INT_PIN & (1<<INT)); */
+ /* } */
+
led_on();
SPI_CS_PORT &= ~(1<<CS);
_delay_us(100);
@@ -138,7 +150,13 @@ void IDM_ReadData(void) uint8_t int_state = (INT_PIN & (1<<INT));
while(!int_state) {
uint8_t ReceivedByte = SPI_TransferByte(0);
+ /* if(ReceivedByte == tmp_cnt) */
+ /* RingBuffer_Insert(&SPItoUSB_Buffer, '.'); */
+ /* else */
+ /* RingBuffer_Insert(&SPItoUSB_Buffer, 'e'); */
RingBuffer_Insert(&SPItoUSB_Buffer, ReceivedByte);
+ tmp_cnt++;
+
if(RingBuffer_IsFull(&SPItoUSB_Buffer))
break;
_delay_us(50);
diff --git a/software/idm/idm.asm b/software/idm/idm.asm index cb4ffcd..d779b4b 100644 --- a/software/idm/idm.asm +++ b/software/idm/idm.asm @@ -138,6 +138,8 @@ endif ;; } int_adc bcf PIR1,ADIF + retfie + btfsc OVERRUN retfie ;; movlb .1 @@ -182,6 +184,13 @@ int_spi int_spi_0 btfss CMD_READ retfie + + incf TMP,f + movlb .4 + movf TMP,w + movwf SSP1BUF + retfie + movlb .0 call rbuf_next btfss UNDERRUN @@ -190,17 +199,15 @@ int_spi_0 goto int_fsr_norestore int_spi_0_loadnext - movlb .4 + movlb .4 movf INDFR,w - ;; incf TMP,f - ;; movf TMP,w movwf SSP1BUF goto int_fsr_norestore int_spi_r - movf INDFR,w - btfss UNDERRUN - ;; movf TMP,w + ;; movf INDFR,w + ;; btfss UNDERRUN + movf TMP,w movwf SSP1BUF clrf CMDS bsf CMD_READ @@ -330,9 +337,9 @@ init movlb .4 movlw b'01000000' ; SMP=0,CKE=1 movwf SSP1STAT - movlw b'00010000' + movlw b'00010000' ; BOEN=1 movwf SSP1CON3 - movlw b'00100100' + movlw b'00100100' ; SSPEN=1,CKP=0,SSPM=0100(SPI Slave with SS) movwf SSP1CON1 if DEBUG == 1 bsf DBG0 ; Pull-up for DBG0 @@ -354,15 +361,14 @@ endif movwf ADCON1 movlw b'00001101' ; AN3, ADC On movwf ADCON0 - movlw b'01001000' ; ADIE,SSPIE + ;; movlw b'01001000' ; ADIE,SSPIE + movlw b'00001000' ; SSPIE movwf PIE1 movlw b'01011111' ; Enable Pull UPs, disable T0CKI movwf OPTION_REG ;; BANK 0 movlb .0 - movlw .124 ; 8 kHz @ 16MHz - movwf PR2 clrf TMR1H ; reset TMR1 clrf TMR1L movlw b'00100000' ; Source Fosc/4, Prescaler 1:4, LP-Osc off, Sync, Timer off @@ -376,6 +382,7 @@ endif bsf INT call buf_init clrf CMDS + clrf TMP bsf INTCON,GIE @@ -386,15 +393,19 @@ main if DEBUG == 1 bcf SPEAKER btfss DBG0 - goto enable_t1 + bcf INT + btfsc DBG0 + bsf INT - btfsc T1CON,TMR1ON - bcf T1CON,TMR1ON - goto main +;; goto enable_t1 + +;; btfsc T1CON,TMR1ON +;; bcf T1CON,TMR1ON +;; goto main -enable_t1 - btfss T1CON,TMR1ON - bsf T1CON,TMR1ON +;; enable_t1 +;; btfss T1CON,TMR1ON +;; bsf T1CON,TMR1ON endif btfss CS goto main |