From bd4eb20d5ef383b1e49141313a634b4d63520e26 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 8 Jul 2011 00:39:51 +0200 Subject: [PATCH] 1st attempt at sending a packet --- firmware/applications/funk.c | 38 ++++++++++++++++++++++++++++++++++++ firmware/funk/nrf24l01p.c | 27 +++++++++++++++++++++---- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/firmware/applications/funk.c b/firmware/applications/funk.c index 74f6caa..ea19a3c 100644 --- a/firmware/applications/funk.c +++ b/firmware/applications/funk.c @@ -62,6 +62,41 @@ void f_recv(void){ }; +void f_send(void){ + static char ctr=1; + int dx=0; + int dy=8; + uint8_t buf[32]; + int status; + int crc; + + buf[0]=0x05; // ID + buf[1]=0xEC; // ID + buf[2]=0xff; + buf[3]=0xff; // Send intensity + + buf[4]=0x00; // ctr + buf[5]=0x00; // ctr + buf[6]=0x00; // ctr + buf[7]=ctr++; // ctr + + buf[8]=0xff; + buf[9]=0xff; + buf[10]=0xff; + buf[11]=0xff; + buf[12]=0xff; + buf[13]=0xff; + + crc=crc16(buf,14); + buf[14]=crc & 0xff; // CRC + buf[15]=(crc >>8) & 0xff; // CRC + + status=nrf_snd_pkt_crc(16,buf); + + dx=DoString(0,dy,"St:"); DoInt(dx,dy,status); dy+=8; + +}; + void gotoISP(void) { DoString(0,0,"Enter ISP!"); lcdDisplay(0); @@ -86,12 +121,14 @@ const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP}; const struct MENU_DEF menu_init = {"F Init", &f_init}; const struct MENU_DEF menu_status = {"F Status", &f_status}; const struct MENU_DEF menu_rcv = {"F Recv", &f_recv}; +const struct MENU_DEF menu_snd = {"F Send", &f_send}; const struct MENU_DEF menu_nop = {"---", NULL}; static menuentry menu[] = { &menu_init, &menu_status, &menu_rcv, + &menu_snd, &menu_nop, &menu_ISP, NULL, @@ -214,3 +251,4 @@ void tick_funk(void){ return; }; + diff --git a/firmware/funk/nrf24l01p.c b/firmware/funk/nrf24l01p.c index d63c4b5..e3a0c69 100644 --- a/firmware/funk/nrf24l01p.c +++ b/firmware/funk/nrf24l01p.c @@ -45,22 +45,25 @@ void nrf_write_reg(const uint8_t reg, const uint8_t val){ CS_HIGH(); }; -void nrf_read_long(const uint8_t reg, int len, uint8_t* data){ +void nrf_read_long(const uint8_t cmd, int len, uint8_t* data){ CS_LOW(); - xmit_spi(reg); + xmit_spi(cmd); for(int i=0;i10ys, i think) + CE_LOW(); + + return nrf_cmd_status(C_NOP); +};