move generic max1227 code to separate source file
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-02-15 16:44:12 +01:00
parent a2ec4a4828
commit 82f9d9db4b
4 changed files with 19 additions and 15 deletions

View File

@ -1,11 +1,10 @@
#include "SusHandler.h"
#include "OBSWConfig.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw_hal/linux/spi/SpiComIF.h>
#include "OBSWConfig.h"
SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId)
: DeviceHandlerBase(objectId, comIF, comCookie), divider(5), dataset(this) {}
@ -87,6 +86,7 @@ ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {
using namespace max1227;
switch (deviceCommand) {
case (SUS::WRITE_SETUP): {
if (clkMode == ClkModes::INT_CLOCKED) {
@ -220,10 +220,6 @@ ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localData
void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediately = enable; }
uint8_t SusHandler::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
}
void SusHandler::printDataset() {
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS == 1
if (divider.checkAndIncrement()) {

View File

@ -5,6 +5,7 @@
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include "devicedefinitions/SusDefinitions.h"
#include "mission/devices/max1227.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
/**
@ -25,13 +26,6 @@ class SusHandler : public DeviceHandlerBase {
public:
enum ClkModes { INT_CLOCKED, EXT_CLOCKED, EXT_CLOCKED_WITH_TEMP };
enum ScanModes : uint8_t {
CHANNELS_0_TO_N = 0b00,
CHANNEL_N_TO_HIGHEST = 0b01,
N_REPEATEDLY = 0b10,
N_ONCE = 0b11
};
static const uint8_t FIRST_WRITE = 7;
SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
@ -59,8 +53,6 @@ class SusHandler : public DeviceHandlerBase {
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp);
private:
static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER;

View File

@ -1 +1,5 @@
#include "max1227.h"
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
}

View File

@ -1,8 +1,20 @@
#ifndef MISSION_DEVICES_MAX1227_H_
#define MISSION_DEVICES_MAX1227_H_
#include <cstdint>
namespace max1227 {
enum ScanModes : uint8_t {
CHANNELS_0_TO_N = 0b00,
CHANNEL_N_TO_HIGHEST = 0b01,
N_REPEATEDLY = 0b10,
N_ONCE = 0b11
};
uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp);
}
#endif /* MISSION_DEVICES_MAX1227_H_ */