Sending works!

This commit is contained in:
Stefan `Sec` Zehl 2011-07-09 22:49:24 +02:00
parent d2a31aa6b0
commit 51286999ea
2 changed files with 21 additions and 15 deletions

View File

@ -12,6 +12,9 @@
void f_init(void){
nrf_init();
int dx=0;
int dy=8;
dx=DoString(0,dy,"Done."); ;dy+=8;
};
#define CS_LOW() {gpioSetValue(RB_SPI_NRF_CS, 0); gpioSetValue(3,2,0);}
@ -72,9 +75,9 @@ void f_send(void){
int status;
uint16_t crc;
buf[0]=0x05; // ID
buf[1]=0xEC; // ID
buf[2]=0xff;
buf[0]=0x10; // Length: 16 bytes
buf[1]=0x17; // Proto - fixed at 0x17?
buf[2]=0xff; // Flags (0xff)
buf[3]=0xff; // Send intensity
buf[4]=0x00; // ctr
@ -82,20 +85,20 @@ void f_send(void){
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;
buf[8]=0x0; // Object id
buf[9]=0x0;
buf[10]=0x05;
buf[11]=0xec;
buf[12]=0xff; // salt (0xffff always?)
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;
dx=DoString(0,dy,"St:"); DoIntX(dx,dy,status); dy+=8;
};
@ -129,6 +132,7 @@ static const struct MENU mainmenu = {"Mainmenu", menu};
void main_funk(void) {
backlightInit();
font=&Font_7x8;
while (1) {
lcdFill(0); // clear display buffer

View File

@ -4,7 +4,7 @@
#define CHANNEL_BEACON 81
#define DEFAULT_SPEED R_RF_SETUP_DR_2M
#define MAC_BEACON "BEACO"
#define MAC_BEACON "\x1\x2\x3\x2\1"
/*-----------------------------------------------------------------------*/
/* Transmit a byte via SPI */
@ -27,8 +27,8 @@ void nrf_cmd(uint8_t cmd){
uint8_t nrf_cmd_status(uint8_t cmd){
CS_LOW();
sspSendReceive(0, &cmd, 1);
return cmd;
CS_HIGH();
return cmd;
};
void nrf_cmd_rw_long(uint8_t* data, int len){
@ -93,7 +93,7 @@ void nrf_init() {
);
nrf_write_reg(R_RX_PW_P0,16);
nrf_write_reg_long(R_RX_ADDR_P0,5,(uint8_t*)"\x1\x2\x3\x2\1");
nrf_write_reg_long(R_RX_ADDR_P0,5,(uint8_t*)MAC_BEACON);
// nrf_write_reg(R_RX_PW_P1,16);
// nrf_write_reg_long(R_RX_ADDR_P1,5,"R0KET");
@ -158,6 +158,7 @@ int nrf_rcv_pkt_time(int maxtime, int maxsize, uint8_t * pkt){
};
char nrf_snd_pkt_crc(int size, uint8_t * pkt){
char status;
nrf_write_reg(R_CONFIG,
R_CONFIG_PWR_UP| // Power on
@ -170,6 +171,7 @@ char nrf_snd_pkt_crc(int size, uint8_t * pkt){
delayms(10); // Send it. (only needs >10ys, i think)
CE_LOW();
return nrf_cmd_status(C_NOP);
};
CS_LOW(); status=C_NOP; sspSendReceive(0, &status, 1); CS_HIGH();
return status;
};