iitm sat
/
Beacon_test_code
TESTING CONNECTIONS IN BCN
main.cpp
- Committer:
- spacelab
- Date:
- 2016-04-13
- Revision:
- 0:2211888e98cf
File content as of revision 0:2211888e98cf:
#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"); }