summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2012-06-22 20:12:13 +0000
committerChristian Pointner <equinox@mur.at>2012-06-22 20:12:13 +0000
commitc7d481809a9827abbd2d73509b167c42cb841dc4 (patch)
tree2c8925f7299d1efaf8e628526166c78c730b6236 /software
parentrx detect works, still receiving mostly noise (diff)
small refactoring
some time tests .. not working yet :( git-svn-id: https://svn.spreadspace.org/mur.sat@551 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/idm-test/idm-test.c13
-rw-r--r--software/idm/idm.asm38
2 files changed, 24 insertions, 27 deletions
diff --git a/software/idm-test/idm-test.c b/software/idm-test/idm-test.c
index f50a57f..49fe3fc 100644
--- a/software/idm-test/idm-test.c
+++ b/software/idm-test/idm-test.c
@@ -43,7 +43,7 @@
/* Global I/O Buffers: */
static RingBuffer_t SPItoUSB_Buffer;
-static uint8_t SPItoUSB_Buffer_Data[64];
+static uint8_t SPItoUSB_Buffer_Data[16];
/** LUFA CDC Class driver interface configuration and state information. This structure is
* passed to all CDC Class driver functions, so that multiple instances of the same class
@@ -93,6 +93,8 @@ void EVENT_USB_Device_ControlRequest(void)
#define INT_PIN PIND
#define INT 0
+volatile unsigned char cnt = 0;
+
void SetupHardware(void)
{
MCUSR &= ~(1 << WDRF);
@@ -104,7 +106,7 @@ void SetupHardware(void)
TCCR0B = (1 << CS02);
- SPI_Init(SPI_SPEED_FCPU_DIV_8 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
+ SPI_Init(SPI_SPEED_FCPU_DIV_64 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING);
SPI_CS_DDR |= (1<<CS);
SPI_CS_PORT |= (1<<CS);
@@ -135,16 +137,17 @@ void IDM_ReadData(void)
_delay_us(30);
uint8_t int_state = (INT_PIN & (1<<INT));
while(!int_state) {
- uint8_t ReceivedByte = SPI_ReceiveByte();
+ uint8_t ReceivedByte = SPI_TransferByte(0);
RingBuffer_Insert(&SPItoUSB_Buffer, ReceivedByte);
if(RingBuffer_IsFull(&SPItoUSB_Buffer))
break;
- _delay_us(25);
+ _delay_us(50);
int_state = (INT_PIN & (1<<INT));
}
- _delay_us(10);
+ _delay_us(30);
SPI_CS_PORT |= (1<<CS);
+ _delay_us(50);
led_off();
}
diff --git a/software/idm/idm.asm b/software/idm/idm.asm
index 0782613..cb4ffcd 100644
--- a/software/idm/idm.asm
+++ b/software/idm/idm.asm
@@ -145,7 +145,9 @@ int_adc
movf TMP,w
movwf INDFW
incf TMP,f
+ movlb .0
call wbuf_next
+ bcf INT
goto int_fsr_norestore
;; void sspInterrupt()
@@ -180,15 +182,25 @@ int_spi
int_spi_0
btfss CMD_READ
retfie
+ movlb .0
call rbuf_next
- movf INDFR,w
btfss UNDERRUN
+ goto int_spi_0_loadnext
+ bsf INT
+ goto int_fsr_norestore
+
+int_spi_0_loadnext
+ 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
movwf SSP1BUF
clrf CMDS
bsf CMD_READ
@@ -204,7 +216,7 @@ int_fsr_norestore
movwf FSR1H_SHAD
movf FSR1L,w
movwf FSR1L_SHAD
- retfie
+ retfie
;; -------------------------------------
;; SUBROUTINES
@@ -225,15 +237,10 @@ buf_init
movwf FSRRL
bcf OVERRUN
bsf UNDERRUN
-
- movf BSR,w
- clrf BSR
- bsf INT
if DEBUG == 1
bcf DBG1
bsf DBG2
endif
- movwf BSR
return
;; -------------------
@@ -254,13 +261,9 @@ wbuf_next
inc_fsr FSRW,FSRWH,FSRWL
bcf UNDERRUN
- movf BSR,w
- clrf BSR
- bcf INT
if DEBUG == 1
bcf DBG2
endif
- movwf BSR
movf FSRRH,w
xorwf FSRWH,w
@@ -272,10 +275,7 @@ endif
return
bsf OVERRUN
if DEBUG == 1
- movf BSR,w
- clrf BSR
bsf DBG1
- movwf BSR
endif
return
@@ -298,10 +298,7 @@ rbuf_next
inc_fsr FSRR,FSRRH,FSRRL
bcf OVERRUN
if DEBUG == 1
- movf BSR,w
- clrf BSR
bcf DBG1
- movwf BSR
endif
movf FSRWH,w
@@ -313,13 +310,9 @@ endif
btfss STATUS,Z
return
bsf UNDERRUN
- movf BSR,w
- clrf BSR
- bsf INT
if DEBUG == 1
bsf DBG2
endif
- movwf BSR
return
;; -------------------------------------
@@ -335,7 +328,7 @@ init
;; BANK 4
movlb .4
- movlw b'01000000'
+ movlw b'01000000' ; SMP=0,CKE=1
movwf SSP1STAT
movlw b'00010000'
movwf SSP1CON3
@@ -380,6 +373,7 @@ endif
movwf INTCON
bcf FILTER_EN
+ bsf INT
call buf_init
clrf CMDS
clrf TMP