Skip to content
Snippets Groups Projects
Commit 768a3b4b authored by Nicolò's avatar Nicolò
Browse files

MY_LIS3DSH.h rename + copyright + doxygen

Renamed class to MY_LIS3DSH to avoid clash, added copyright header, using doxygen convention
parent 9a720b1b
Branches
Tags
No related merge requests found
/* /* Copyright (c) 2023 Skyward Experimental Rocketry
* My driver for the 3-axis accelerometer LIS3DSH * Author: Nicolò Caruso
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/ */
#pragma once #pragma once
#include <diagnostic/PrintLogger.h> #include <diagnostic/PrintLogger.h>
...@@ -13,41 +31,79 @@ ...@@ -13,41 +31,79 @@
#include "MY_LIS3DSHData.h" #include "MY_LIS3DSHData.h"
#include "MY_LIS3DSHDefs.h" #include "MY_LIS3DSHDefs.h"
namespace Boardcore{ namespace Boardcore
// {
class LIS3DSH : public Sensor<LIS3DSHData>{ /*! MY_LIS3DSH class for the LIS3DSH sensor */
class MY_LIS3DSH : public Sensor<MY_LIS3DSHData>
{
public: public:
// Constructor /**
LIS3DSH(SPIBusInterface& spiBus, * @brief Constructor without spi configuration
miosix::GpioPin cs, *
LIS3DSHDefs::OutputDataRate odr, * @param spiBus : SPI bus of the discovery, connected to the sensor
LIS3DSHDefs::BlockDataUpdate bdu, * @param cs : Sensor's Chip Select
LIS3DSHDefs::FullScaleRange fs // Full scale range * @param odr : Sensor's Output Data Rate
* @param bdu : Sensor's Block Data Update
* @param fs : Sensor's Full Scale Range
* */
MY_LIS3DSH(SPIBusInterface& spiBus, miosix::GpioPin cs,
MY_LIS3DSHDefs::OutputDataRate odr,
MY_LIS3DSHDefs::BlockDataUpdate bdu,
MY_LIS3DSHDefs::FullScaleRange fs // Full scale range
); );
LIS3DSH(SPIBusInterface& spiBus, /**
miosix::GpioPin cs, * @brief Constructor with spi configuration
SPIBusConfig cfg, *
LIS3DSHDefs::OutputDataRate odr, * @param spiBus : SPI bus of the discovery, connected to the sensor
LIS3DSHDefs::BlockDataUpdate bdu, * @param cs : Sensor's Chip Select
LIS3DSHDefs::FullScaleRange fs // Full scale range * @param cfg : SPI bus configuration
* @param odr : Sensor's Output Data Rate
* @param bdu : Sensor's Block Data Update
* @param fs : Sensor's Full Scale Range
* */
MY_LIS3DSH(SPIBusInterface& spiBus, miosix::GpioPin cs, SPIBusConfig cfg,
MY_LIS3DSHDefs::OutputDataRate odr,
MY_LIS3DSHDefs::BlockDataUpdate bdu,
MY_LIS3DSHDefs::FullScaleRange fs /*! Full scale range */
); );
static SPIBusConfig getDefaultSPIConfig(); // Gets the default SPI static SPIBusConfig getDefaultSPIConfig(); /*! Gets the default SPI configuration */
/**
* @brief Initialization function for the LIS3DSH sensor
* It does configure the registers
* @returns True if the initialization has been completed correctly
* @returns False otherwise
*/
bool init(); bool init();
LIS3DSHData sampleImpl() override; /**
* @brief Samples the data from the sensor's registers.
*
* Converts the data read from spi to an MY_LIS3DSHData structure
*
* @returns A copy of the last sampled data of MY_LIS3DSHData type.
*/
MY_LIS3DSHData sampleImpl() override;
/**
* @brief Simply returns true.
*
* @returns True, always.
*/
bool selfTest(); bool selfTest();
private:
/*! SPI driver for transactions */
SPISlave spi; SPISlave spi;
LIS3DSHDefs::OutputDataRate odr; /*! odr, bdu, fs get from the constructor. */
LIS3DSHDefs::BlockDataUpdate bdu; MY_LIS3DSHDefs::OutputDataRate odr;
LIS3DSHDefs::FullScaleRange fs; MY_LIS3DSHDefs::BlockDataUpdate bdu;
MY_LIS3DSHDefs::FullScaleRange fs;
bool initialized; bool initialized;
PrintLogger logger = Logging::getLogger("li3dsh"); PrintLogger logger = Logging::getLogger("li3dsh");
}; };
} // namespace Boardcore } /*! namespace Boardcore */
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment