void A7105_WriteData(u8 *dpbuffer, u8 len, u8 channel) { int i; CS_LO(); spi_xfer(SPI2, A7105_RST_WRPTR); spi_xfer(SPI2, 0x05); for (i = 0; i < len; i++) spi_xfer(SPI2, dpbuffer[i]); CS_HI(); A7105_WriteReg(0x0F, channel); CS_LO(); spi_xfer(SPI2, A7105_TX); CS_HI(); }
void CC2500_WriteReg(u8 address, u8 data) { CS_LO(); spi_xfer(SPI2, address); spi_xfer(SPI2, data); CS_HI(); }
void CYRF_WriteRegister(u8 address, u8 data) { CS_LO(); spi_xfer(SPI1, 0x80 | address); spi_xfer(SPI1, data); CS_HI(); }
void A7105_WriteReg(u8 address, u8 data) { CS_LO(); PROTOSPI_xfer(address); PROTOSPI_xfer(data); CS_HI(); }
void A7105_WriteData(u8 *dpbuffer, u8 len, u8 channel) { int i; CS_LO(); PROTOSPI_xfer(A7105_RST_WRPTR); PROTOSPI_xfer(0x05); for (i = 0; i < len; i++) PROTOSPI_xfer(dpbuffer[i]); CS_HI(); A7105_WriteReg(0x0F, channel); CS_LO(); PROTOSPI_xfer(A7105_TX); CS_HI(); }
static u8 Strobe(u8 state) { CS_LO(); u8 res = PROTOSPI_xfer(state); CS_HI(); return res; }
uint8_t nRF24L01::strobe(uint8_t state) { CS_LO(); uint8_t res = PROTOSPI_xfer(state); CS_HI(); return res; }
static u8 Strobe(u8 state) { CS_LO(); u8 res = spi_xfer(SPI2, state); CS_HI(); return res; }
u8 NRF24L01_ReadReg(u8 reg) { CS_LO(); PROTOSPI_xfer(R_REGISTER | (REGISTER_MASK & reg)); u8 data = PROTOSPI_xfer(0xFF); CS_HI(); return data; }
u8 NRF24L01_Activate(u8 code) { CS_LO(); u8 res = PROTOSPI_xfer(ACTIVATE); PROTOSPI_xfer(code); CS_HI(); return res; }
u8 NRF24L01_WriteReg(u8 reg, u8 data) { CS_LO(); u8 res = PROTOSPI_xfer(W_REGISTER | (REGISTER_MASK & reg)); PROTOSPI_xfer(data); CS_HI(); return res; }
u8 CC2500_ReadReg(u8 address) { CS_LO(); spi_xfer(SPI2, CC2500_READ_SINGLE | address); u8 data = spi_xfer(SPI2, 0); CS_HI(); return data; }
uint8_t nRF24L01::readReg(uint8_t reg) { CS_LO(); PROTOSPI_xfer(R_REGISTER | (REGISTER_MASK & reg)); uint8_t data = PROTOSPI_xfer(0xFF); CS_HI(); return data; }
uint8_t nRF24L01::writeReg(uint8_t reg, uint8_t data) { CS_LO(); uint8_t res = PROTOSPI_xfer(W_REGISTER | (REGISTER_MASK & reg)); PROTOSPI_xfer(data); CS_HI(); return res; }
uint8_t nRF24L01::activate(uint8_t code) { CS_LO(); uint8_t res = PROTOSPI_xfer(ACTIVATE); PROTOSPI_xfer(code); CS_HI(); return res; }
u8 NRF24L01_ReadReg(u8 reg) { CS_LO(); spi_xfer(SPI2, R_REGISTER | (REGISTER_MASK & reg)); u8 data = spi_xfer(SPI2, 0xFF); CS_HI(); return data; }
u8 NRF24L01_WriteReg(u8 reg, u8 data) { CS_LO(); u8 res = spi_xfer(SPI2, W_REGISTER | (REGISTER_MASK & reg)); spi_xfer(SPI2, data); CS_HI(); return res; }
u8 NRF24L01_Activate(u8 code) { CS_LO(); u8 res = spi_xfer(SPI2, ACTIVATE); spi_xfer(SPI2, code); CS_HI(); return res; }
u8 CC2500_ReadReg(u8 address) { CS_LO(); PROTOSPI_xfer(CC2500_READ_SINGLE | address); u8 data = PROTOSPI_xfer(0); CS_HI(); return data; }
void CYRF_WritePreamble(u32 preamble) { CS_LO(); spi_xfer(SPI2, 0x80 | 0x24); spi_xfer(SPI2, preamble & 0xff); spi_xfer(SPI2, (preamble >> 8) & 0xff); spi_xfer(SPI2, (preamble >> 16) & 0xff); CS_HI(); }
/* Find out, do we have SPI switch board installed */ static void detect() { switch_detected = 0; u32 res; unsigned cyrf_present = 0; flash_present = 0; printf("Detecting SPI Switch\n"); /* Check that CYRF6936 is present */ /* CYRF6936 reset */ CS_HI(); Delay(100); CS_LO(); Delay(100); GPIO_pin_clear(PROTO_SPI.csn); spi_xfer(PROTO_SPI.spi, 0x10); res = spi_xfer(PROTO_SPI.spi, 0); GPIO_pin_set(PROTO_SPI.csn); if (res == 0xa5) { printf("CYRF6936 directly available, no switch\n"); return; } CS_HI(); /* Switch to CYRF6936 module */ UseModule(MODULE_CYRF6936); /* Check that CYRF6936 is present */ SPISwitch_CYRF6936_RESET(1); Delay(100); SPISwitch_CYRF6936_RESET(0); Delay(100); GPIO_pin_clear(PROTO_SPI.csn); spi_xfer(PROTO_SPI.spi, 0x10); res = spi_xfer(PROTO_SPI.spi, 0); GPIO_pin_set(PROTO_SPI.csn); if (res == 0xa5) { printf("CYRF6936 found at pos 3\n"); cyrf_present = 1; } /* Switch to flash module */ UseModule(MODULE_FLASH); /* Check that JEDEC ID command returns non-zero and not all bits high */ GPIO_pin_clear(PROTO_SPI.csn); spi_xfer(PROTO_SPI.spi, 0x9F); res = (u8)spi_xfer(PROTO_SPI.spi, 0); res <<= 8; res |= (u8)spi_xfer(PROTO_SPI.spi, 0); res <<= 8; res |= (u8)spi_xfer(PROTO_SPI.spi, 0); GPIO_pin_set(PROTO_SPI.csn); if (res && res != 0xFFFFFF) { printf("Flash detected, JEDEC ID: '%X'\n", res); flash_present = 1; } switch_detected = cyrf_present || flash_present; printf("SPI Switch %s\n", switch_detected ? "detected" : "absent"); }
void A7105_WriteID(u32 id) { CS_LO(); spi_xfer(SPI2, 0x06); spi_xfer(SPI2, (id >> 24) & 0xFF); spi_xfer(SPI2, (id >> 16) & 0xFF); spi_xfer(SPI2, (id >> 8) & 0xFF); spi_xfer(SPI2, (id >> 0) & 0xFF); CS_HI(); }
static void SetExtraBits(u8 mask, int state) { // if (!!(extra_bits & mask) == state) return; if (state) extra_bits |= mask; else extra_bits &= ~mask; u8 cmd = (last_module_used & 0x07) | extra_bits; CS_LO(); spi_xfer(PROTO_SPI.spi, cmd); CS_HI(); }
void A7105_WriteID(u32 id) { CS_LO(); PROTOSPI_xfer(0x06); PROTOSPI_xfer((id >> 24) & 0xFF); PROTOSPI_xfer((id >> 16) & 0xFF); PROTOSPI_xfer((id >> 8) & 0xFF); PROTOSPI_xfer((id >> 0) & 0xFF); CS_HI(); }
void CC2500_WriteRegisterMulti(u8 address, const u8 data[], u8 length) { CS_LO(); spi_xfer(SPI2, CC2500_WRITE_BURST | address); for(int i = 0; i < length; i++) { spi_xfer(SPI2, data[i]); } CS_HI(); }
u8 CYRF_ReadRegister(u8 address) { u8 data; CS_LO(); spi_xfer(SPI2, address); data = spi_xfer(SPI2, 0); CS_HI(); return data; }
u8 A7105_ReadReg(u8 address) { u8 data; CS_LO(); PROTOSPI_xfer(0x40 | address); /* Wait for tx completion before spi shutdown */ data = PROTOSPI_read3wire(); CS_HI(); return data; }
u8 NRF24L01_WriteRegisterMulti(u8 reg, const u8 data[], u8 length) { CS_LO(); u8 res = PROTOSPI_xfer(W_REGISTER | ( REGISTER_MASK & reg)); for (u8 i = 0; i < length; i++) { PROTOSPI_xfer(data[i]); } CS_HI(); return res; }
u8 NRF24L01_ReadRegisterMulti(u8 reg, u8 data[], u8 length) { CS_LO(); u8 res = PROTOSPI_xfer(R_REGISTER | (REGISTER_MASK & reg)); for(u8 i = 0; i < length; i++) { data[i] = PROTOSPI_xfer(0xFF); } CS_HI(); return res; }
u8 NRF24L01_ReadPayload(u8 *data, u8 length) { CS_LO(); u8 res = PROTOSPI_xfer(R_RX_PAYLOAD); for(u8 i = 0; i < length; i++) { data[i] = PROTOSPI_xfer(0xFF); } CS_HI(); return res; }