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.
Fork of X_NUCLEO_COMMON_SPI3W by
Revision 25:e4f6488865d1, committed 2017-08-31
- Comitter:
- mapellil
- Date:
- Thu Aug 31 11:24:35 2017 +0200
- Parent:
- 24:95fd537e9725
- Commit message:
- Modifications to support mbed-os pull req https://github.com/ARMmbed/mbed-os/pull/4975
Changed in this revision
DevSPI3W/SPI3W.cpp | Show annotated file Show diff for this revision Revisions of this file |
DevSPI3W/SPI3W.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DevSPI3W/SPI3W.cpp Wed May 24 13:21:01 2017 +0000 +++ b/DevSPI3W/SPI3W.cpp Thu Aug 31 11:24:35 2017 +0200 @@ -75,18 +75,13 @@ * @retval 1 in case of failure */ uint8_t SPI3W::Sensor_IO_SPI_Write( DigitalOut * _cs_pin, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ) -{ - uint8_t i; - +{ // Select the correct device Sensor_IO_SPI_CS_Enable(_cs_pin); - write(WriteAddr); - - for(i=0;i<nBytesToWrite;i++) - { - write(pBuffer[i]); - } + write(WriteAddr); + write((char *)pBuffer, (int) nBytesToWrite, NULL, 0); + // Deselect the device Sensor_IO_SPI_CS_Disable(_cs_pin); @@ -107,31 +102,6 @@ return Sensor_IO_SPI_Write( _cs_pin, WriteAddr, pBuffer, nBytesToWrite ); } - -/** - * @brief This function reads a single byte on SPI 3-wire. - * @param xSpiHandle : SPI Handler. - * @param val : value. - * @retval None - */ -void SPI3W::SPI_Read(SPI_HandleTypeDef* xSpiHandle, uint8_t *val) -{ - *val = spi_slave_read(&_spi); -} - -/** - * @brief This function reads multiple bytes on SPI 3-wire. - * @param xSpiHandle: SPI Handler. - * @param val: value. - * @param nBytesToRead: number of bytes to read. - * @retval None - */ -void SPI3W::SPI_Read_nBytes(SPI_HandleTypeDef* xSpiHandle, uint8_t *val, uint16_t nBytesToRead) -{ - for (int i=0; i<nBytesToRead; i++) *(val+i) = spi_slave_read(&_spi); -} - - /** * @brief Reads a from the sensor to buffer * @param handle instance handle @@ -146,10 +116,9 @@ /* Select the correct device */ Sensor_IO_SPI_CS_Enable(_cs_pin); - /* Write Reg Address with RD bit*/ - write(ReadAddr | 0x80); - - SPI_Read_nBytes(&_spi.spi.handle, pBuffer, nBytesToRead); + /* Write RD Reg Address with RD bit*/ + uint8_t TxByte = ReadAddr | 0x80; + write((char *)&TxByte, 1, (char *)pBuffer, (int) nBytesToRead); /* Deselect the device */ Sensor_IO_SPI_CS_Disable(_cs_pin);
--- a/DevSPI3W/SPI3W.h Wed May 24 13:21:01 2017 +0000 +++ b/DevSPI3W/SPI3W.h Thu Aug 31 11:24:35 2017 +0200 @@ -68,8 +68,6 @@ private: uint8_t Sensor_IO_Read( DigitalOut * _cs_pin, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); uint8_t Sensor_IO_SPI_Read( DigitalOut * _cs_pin, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); - void SPI_Read(SPI_HandleTypeDef* xSpiHandle, uint8_t *val); - void SPI_Read_nBytes(SPI_HandleTypeDef* xSpiHandle, uint8_t *val, uint16_t nBytesToRead); uint8_t Sensor_IO_Write( DigitalOut * _cs_pin, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); uint8_t Sensor_IO_SPI_Write( DigitalOut * _cs_pin, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite );