mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-29 05:17:33 +00:00
Big assert / debug clean up
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef STA_PLATFORM_RASPI
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string.h>
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
RaspiI2c::RaspiI2c(I2cNode node, Mutex * mutex, bool persistent_open)
|
||||
: I2c{mutex}, persistent_open_{persistent_open}
|
||||
RaspiI2C::RaspiI2C(I2CNode node, Mutex * mutex, bool persistent_open)
|
||||
: I2C{mutex}, persistent_open_{persistent_open}
|
||||
{
|
||||
// Safer version of malloc + strcpy
|
||||
i2cdev_ = strdup(node == I2cNode::DEV_1 ? "/dev/i2c-1" : "/dev/i2c-2");
|
||||
i2cdev_ = strdup(node == I2CNode::DEV_1 ? "/dev/i2c-1" : "/dev/i2c-2");
|
||||
|
||||
STA_ASSERT(i2cdev_ != nullptr);
|
||||
}
|
||||
|
||||
RaspiI2c::~RaspiI2c()
|
||||
RaspiI2C::~RaspiI2C()
|
||||
{
|
||||
if (i2cdev_ != NULL ) {
|
||||
free(i2cdev_);
|
||||
@@ -37,35 +37,35 @@ namespace sta
|
||||
}
|
||||
}
|
||||
|
||||
void RaspiI2c::transfer(uint8_t value)
|
||||
void RaspiI2C::transfer(uint8_t value)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
write(i2cfd_, &value, 1);
|
||||
}
|
||||
|
||||
void RaspiI2c::transfer16(uint16_t value)
|
||||
void RaspiI2C::transfer16(uint16_t value)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
write(i2cfd_, &value, 2);
|
||||
}
|
||||
|
||||
void RaspiI2c::transfer(const uint8_t * buffer, size_t size)
|
||||
void RaspiI2C::transfer(const uint8_t * buffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
write(i2cfd_, buffer, size);
|
||||
}
|
||||
|
||||
void RaspiI2c::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size)
|
||||
void RaspiI2C::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
// TODO: Is this even possible in i2c?
|
||||
}
|
||||
|
||||
void RaspiI2c::receive(uint8_t * buffer, size_t size)
|
||||
void RaspiI2C::receive(uint8_t * buffer, size_t size)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace sta
|
||||
}
|
||||
}
|
||||
|
||||
void RaspiI2c::fill(uint8_t value, size_t count)
|
||||
void RaspiI2C::fill(uint8_t value, size_t count)
|
||||
{
|
||||
STA_ASSERT(open_);
|
||||
|
||||
@@ -88,17 +88,9 @@ namespace sta
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
void RaspiI2c::selectAddress(uint16_t address)
|
||||
void RaspiI2C::acquire()
|
||||
{
|
||||
if (ioctl(i2cfd_, I2C_SLAVE, address) < 0)
|
||||
{
|
||||
printf("Failed to send the slave address.");
|
||||
}
|
||||
}
|
||||
|
||||
void RaspiI2c::acquire()
|
||||
{
|
||||
I2c::acquire();
|
||||
I2C::acquire();
|
||||
|
||||
if (open_) {
|
||||
return;
|
||||
@@ -110,17 +102,17 @@ namespace sta
|
||||
STA_ASSERT(i2cfd_ >= 0);
|
||||
}
|
||||
|
||||
void RaspiI2c::release()
|
||||
void RaspiI2C::release()
|
||||
{
|
||||
if (!persistent_open_ && open_) {
|
||||
close(i2cfd_);
|
||||
}
|
||||
|
||||
I2c::release();
|
||||
I2C::release();
|
||||
}
|
||||
|
||||
RaspiI2cDevice::RaspiI2cDevice(I2c * intf, uint16_t address_10bit, Mutex* mutex, bool master, bool blocking)
|
||||
: I2cDevice { intf, address_10bit }
|
||||
RaspiI2CDevice::RaspiI2CDevice(RaspiI2C * intf, uint16_t address_10bit, Mutex* mutex, bool master, bool blocking)
|
||||
: I2CDevice { intf, address_10bit }
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <sta/devices/raspi/gpio_pin.hpp>
|
||||
#include <sta/bus/spi/settings.hpp>
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
#include <sta/endian.hpp>
|
||||
#include <sta/lang.hpp>
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <sta/devices/raspi/hal.hpp>
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
#include <sta/lang.hpp>
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <sta/devices/raspi/gpio_pin.hpp>
|
||||
#ifdef STA_RASPI_GPIO_ENABLED
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
#include <sta/lang.hpp>
|
||||
|
||||
namespace sta
|
||||
|
@@ -1,8 +1,10 @@
|
||||
#include <sta/devices/stm32/bus/i2c.hpp>
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef STA_PLATFORM_STM32
|
||||
|
||||
namespace sta
|
||||
{
|
||||
STM32I2C::STM32I2C(I2C_HandleTypeDef * handle, Mutex * mutex)
|
||||
@@ -126,3 +128,5 @@ namespace sta
|
||||
}
|
||||
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_STM32
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <sta/devices/stm32/init.hpp>
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
#ifdef STA_STM32_DELAY_US_TIM
|
||||
|
||||
|
Reference in New Issue
Block a user