iitm sat
/
Beacon_test_code
TESTING CONNECTIONS IN BCN
Diff: main.cpp
- Revision:
- 0:2211888e98cf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 13 16:38:24 2016 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +Serial pc(USBTX, USBRX); // tx, rx +//SPI spi(D11, D12, D13); // mosi, miso, sclk +//DigitalOut cs(D10); //slave select or chip select +SPI spi(PTE18, PTE19, PTE17); // mosi, miso, sclk +DigitalOut cs(PTE5); //slave select or chip select +#define RF22_REG_00_DEVICE_TYPE 0x00 + +uint8_t readreg(uint8_t reg) +{ + int val;cs = 0;__disable_irq();spi.write(reg & ~0x80);val = spi.write(0);__enable_irq();cs = 1;return val; +} +int main() +{ + wait(1); // wait for POR to complete //change the timing later + cs=1; // chip must be deselected + wait(1); //change the time later + spi.format(8,0); + spi.frequency(10000000); //10MHz SCLK + if (readreg(RF22_REG_00_DEVICE_TYPE) == 0x08) pc.printf("spi connection valid\n"); + else pc.printf("error in spi connection\n"); +} \ No newline at end of file