Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RTOS_project RTOS_project_fork_01 RTOS_project_fork_02
mmSPI_RTOS.h
00001 #ifndef mmSPI_RTOS_H // include guard. 00002 #define mmSPI_RTOS_H // include guard. 00003 /*----------------------------------------------//------------------------------ 00004 student : m-moore 00005 email : gated.clock@gmail.com 00006 class : embedded RTOS 00007 directory : RTOS_project/mmSPI_RTOS 00008 file : mmSPI_RTOS.h 00009 date : september 19, 2013. 00010 ----copyright-----------------------------------//------------------------------ 00011 licensed for personal and academic use. 00012 commercial use of original code must be approved by the account-holder of 00013 gated.clock@gmail.com 00014 ----description---------------------------------//------------------------------ 00015 this library provides the low-level SPI data and clock signaling 00016 for communication with the altera development board, via four i/o 00017 pins available on the mbed development board's zigbee header. 00018 ----notes---------------------------------------//------------------------------ 00019 ------------------------------------------------//----------------------------*/ 00020 #include "mbed.h" // standard mbed.org class. 00021 //---defines------------------------------------//------------------------------ 00022 #define mmSPI_RTOS_MOSI p29 // SPI interface pin. 00023 #define mmSPI_RTOS_MISO p30 // SPI interface pin. 00024 #define mmSPI_RTOS_SCLK p9 // SPI interface pin. 00025 #define mmCPU_CLK p10 // soft CPU system clock. 00026 //==============================================//============================== 00027 class mmSPI_RTOS 00028 { 00029 public: 00030 mmSPI_RTOS(); // constructor. 00031 ~mmSPI_RTOS(); // destructor. 00032 void allocations(); // object allocations. 00033 00034 void setSPIfrequency (float); // initializations. 00035 void setSendBuffer (char * pcSendBuffer); 00036 void setReceiveBuffer(char * pcReceiveBuffer); 00037 void setNumberOfBytes(int dNumberOfBytes); 00038 00039 // SPI transceive loop. 00040 void transceive_vector(char cPreCPU, char cPreSPI, char cScan, char cPostCPU); 00041 00042 // write/read CPU registers. 00043 void write_register (char cRegister, char cValue); 00044 void write_IR (char cValueH, char cValueL); 00045 char read_register (char cRegister); 00046 void read_all_registers(char * pcRegisters); 00047 00048 // write/read CPU main-memory. 00049 void write_memory(char cHData, char cLdata, char cAddress); 00050 unsigned int read_memory (char cAddress); 00051 00052 void step(); // step the CPU. 00053 00054 void clear_transmit_vector(); // fill with 0. 00055 00056 unsigned long SPIClockCount(); // return SPI clock count. 00057 unsigned long CPUClockCount(); // return CPU clock count. 00058 00059 private: 00060 00061 DigitalOut * pMOSI; // SPI pin. 00062 DigitalOut * pMISO; // SPI pin. 00063 DigitalOut * pSCLK; // SPI pin. 00064 DigitalOut * pCPUclk; // soft cpu clock. 00065 char * pcSend; // SPI transmit vector. 00066 char * pcReceive; // SPI receive vector. 00067 float fSPIfreq; // SPI clock frequency. 00068 float fSPIquarterP; // SPI quarter period. 00069 int dNumBytes; // number of SPI bytes. 00070 int dLoop01; // loop index. 00071 int dLoop02; // loop index. 00072 unsigned long ulSPIclkCount; // SPI clock count. 00073 unsigned long ulCPUclkCount; // CPU clock count. 00074 }; 00075 //----------------------------------------------//------------------------------ 00076 #endif // include guard.
Generated on Wed Jul 13 2022 14:48:55 by
1.7.2