David Giles
/
CM-MBED_RSEDP_Test_Suite_LPC1768_V3
This is a complete listing of the RS-EDP software for the mbed module to support the RS-EDP platform.
SourceFiles/RSEDP_CNTRL_SPI.cpp@0:5b7639d1f2c4, 2010-11-19 (annotated)
- Committer:
- DavidGilesHitex
- Date:
- Fri Nov 19 09:49:16 2010 +0000
- Revision:
- 0:5b7639d1f2c4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidGilesHitex | 0:5b7639d1f2c4 | 1 | /* RS-EDP CNTRL SPI Functions */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 2 | /* ************************** */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 3 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 4 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 5 | /* Includes Here */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 6 | #include "mbed.h" |
DavidGilesHitex | 0:5b7639d1f2c4 | 7 | #include "misra_types.h" /* Standard Misra Types For ARM */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 8 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 9 | #include "mbed_Port_Structure.h" /* mbed module port structure and port functions */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 10 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 11 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 12 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 13 | /* Function Prototpyes */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 14 | void setup_CNTRL_SPI_Master_Mode(void); |
DavidGilesHitex | 0:5b7639d1f2c4 | 15 | uint8_t CNTRL_SPI_Write_Byte(uint8_t data_byte); |
DavidGilesHitex | 0:5b7639d1f2c4 | 16 | uint8_t CNTRL_SPI_Read_Byte(void); |
DavidGilesHitex | 0:5b7639d1f2c4 | 17 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 18 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 19 | /* setup and configure the SPI Peripheral */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 20 | void setup_CNTRL_SPI_Master_Mode(void) |
DavidGilesHitex | 0:5b7639d1f2c4 | 21 | { |
DavidGilesHitex | 0:5b7639d1f2c4 | 22 | /* IO Structure already configures in mbed_Port_Structure.c */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 23 | CNTRL_spi.format(8,3); /* 8 bit, Clock Polarity, Clock Phase */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 24 | CNTRL_spi.frequency(1000000); /* Clock frequency in Hertz */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 25 | } |
DavidGilesHitex | 0:5b7639d1f2c4 | 26 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 27 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 28 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 29 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 30 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 31 | /* Send one byte of data out to the SPI */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 32 | uint8_t CNTRL_SPI_Write_Byte(uint8_t data_byte) |
DavidGilesHitex | 0:5b7639d1f2c4 | 33 | { |
DavidGilesHitex | 0:5b7639d1f2c4 | 34 | uint8_t return_value = 0; |
DavidGilesHitex | 0:5b7639d1f2c4 | 35 | return_value = CNTRL_spi.write(data_byte); |
DavidGilesHitex | 0:5b7639d1f2c4 | 36 | return return_value; |
DavidGilesHitex | 0:5b7639d1f2c4 | 37 | } |
DavidGilesHitex | 0:5b7639d1f2c4 | 38 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 39 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 40 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 41 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 42 | /* Read one byte of data from the SPI */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 43 | uint8_t CNTRL_SPI_Read_Byte(void) |
DavidGilesHitex | 0:5b7639d1f2c4 | 44 | { |
DavidGilesHitex | 0:5b7639d1f2c4 | 45 | uint8_t return_value = 0; |
DavidGilesHitex | 0:5b7639d1f2c4 | 46 | |
DavidGilesHitex | 0:5b7639d1f2c4 | 47 | return_value = CNTRL_spi.write(0x00) ; /* transmit a dummy byte */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 48 | return return_value; /* Return with read in value */ |
DavidGilesHitex | 0:5b7639d1f2c4 | 49 | } |
DavidGilesHitex | 0:5b7639d1f2c4 | 50 |