Files
wordclock/code/main/hal/inc/ISerialBus.h
T
Matthias Mitscherlich d5e389f1bd Fixed ISerialBus interface and added device and register address fields so that future i2c and SPI devices can be addressed, to. Added i2c HAL. Tested, working.
The update on the interface required FunctionStatus and the logger to be updated, too
2024-03-11 17:00:07 +01:00

106 lines
3.7 KiB
C++

// --------------------------------------------------------------------------------------------------------------------
/// \file ISerialBus.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_ISERIALBUS_H_
#define MAIN_HAL_INC_ISERIALBUS_H_
/**
* ISerialBus implementation
* \defgroup ISerialBus
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define NO_DEVICE_ADDRESS (255)
#define NO_REGISTER_ADDRESS (255)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
template<typename T>
class ISerialBus
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Virtual Class Destructor (required for absolute virtual classes)
virtual ~ISerialBus() {}
FunctionStatus open() {status = OPEN; return FUNCTION_STATUS_OK;}
FunctionStatus close() {status = CLOSED; return FUNCTION_STATUS_OK;}
virtual FunctionStatus read(T deviceAddress, T registerAddress, T* buffer, uint32_t length, uint32_t* actualLength) = 0;
virtual FunctionStatus write(T deviceAddress, T registerAddress, T* buffer, uint32_t length) = 0;
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
typedef enum
{
CLOSED = 0,
OPEN
} Status_t;
// The current open/close status of the interface
Status_t status;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_HAL_INC_ISERIALBUS_H_ */