Added some buxfixes to spi code

This commit is contained in:
Dario
2023-05-16 21:15:53 +01:00
parent 0bc924bba2
commit 38bdbbe526
12 changed files with 186 additions and 68 deletions

11
include/sta/config.hpp Normal file
View File

@@ -0,0 +1,11 @@
#ifndef STA_CONFIG
#define STA_CONFIG
// Use the raspberry pi for this project.
#include <sta/raspi/mcu/common.hpp>
// #define DEBUG
#define STA_PRINTF_USE_STDLIB
#define STA_DEBUG_PRINTF
#endif

View File

@@ -70,14 +70,6 @@ namespace sta
*/
void print(uint32_t num, IntegerBase base = IntegerBase::DEC);
/**
* @brief Print integer in selected base.
*
* @param num Integer
* @param base Integer base
*/
void print(size_t num, IntegerBase base = IntegerBase::DEC);
/**
* @brief Print c-string.
*
@@ -143,14 +135,6 @@ namespace sta
*/
void println(uint32_t num, IntegerBase base = IntegerBase::DEC);
/**
* @brief Print integer in selected base followed by a new-line.
*
* @param num Integer
* @param base Integer base
*/
void println(size_t num, IntegerBase base = IntegerBase::DEC);
/**
* @brief Print c-string followed by a new-line.
*

View File

@@ -0,0 +1,44 @@
/**
* @file
* @brief Delay functions.
*
* Configuration:
* * STA_RASPI_DELAY_US_TIM: 1 MHz TIM instance used by sta::delayUs
*
* NOTE: TIM time base must be started before use of sta::delayUs by calling sta::initHAL.
* When using startup system task this is handled automatically.
*/
#ifndef STA_CORE_RASPI_DELAY_HPP
#define STA_CORE_RASPI_DELAY_HPP
// Only enable module on RASPI platform
#include <sta/config.hpp>
#if defined(STA_PLATFORM_RASPI) || defined(DOXYGEN)
#include <cstdint>
namespace sta
{
/**
* @brief Millisecond delay.
*
* @param ms Milliseconds
*/
void delayMs(uint32_t ms);
/**
* @brief Microsecond delay.
*
* @param us Microseconds
*/
void delayUs(uint32_t us);
} // namespace sta
#endif // STA_PLATFORM_RASPI
#endif // STA_CORE_RASPI_DELAY_HPP

View File

@@ -37,12 +37,6 @@ namespace sta
uint8_t pin_;
GpioMode mode_;
};
class DummyGpioPin : public RaspiGpioPin {
DummyGpioPin();
void setState(GpioPinState state) override;
};
} // namespace sta
#endif // STA_RASPI_GPIO_ENABLED

View File

@@ -36,9 +36,15 @@ namespace sta
int spifd_;
bool open_;
const bool persistent_open_;
SPISettings settings_;
uint8_t mode_;
uint8_t dataSize_;
uint8_t bitOrder_;
uint32_t clkSpeed_;
void update_setting(int setting, int value);
int get_setting(int setting, void * rslt_ptr);
void get_setting(int setting, void * rslt_ptr);
void update_settings();
};

View File

@@ -81,8 +81,7 @@ namespace sta
*
* @return %SPI settings
*/
const SPISettings & settings() const;
const SPISettings & settings();
/**
* @brief Acquire usage rights to use the interface.