mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
I2C into nicer wrapper for FreeRToS
This commit is contained in:
32
workspace/TS100/inc/FRToSI2C.hpp
Normal file
32
workspace/TS100/inc/FRToSI2C.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* FRToSI2C.hpp
|
||||
*
|
||||
* Created on: 14Apr.,2018
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef FRTOSI2C_HPP_
|
||||
#define FRTOSI2C_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
class FRToSI2C {
|
||||
public:
|
||||
FRToSI2C(I2C_HandleTypeDef* i2chandle);
|
||||
void MasterTxCpltCallback(); //Normal Tx Callback
|
||||
void MemRxCpltCallback(); //Callback from memory read cycles
|
||||
void MemTxCpltCallback(); //Callback from memory write cycles
|
||||
|
||||
void Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize,
|
||||
uint8_t *pData, uint16_t Size);
|
||||
void Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize,
|
||||
uint8_t *pData, uint16_t Size);
|
||||
|
||||
void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||
|
||||
|
||||
private:
|
||||
I2C_HandleTypeDef* i2c;
|
||||
};
|
||||
|
||||
#endif /* FRTOSI2C_HPP_ */
|
||||
@@ -8,10 +8,11 @@
|
||||
#ifndef LIS2DH12_HPP_
|
||||
#define LIS2DH12_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "LIS2DH12_defines.hpp"
|
||||
class LIS2DH12 {
|
||||
public:
|
||||
LIS2DH12(I2C_HandleTypeDef* i2cHandle);
|
||||
LIS2DH12(FRToSI2C* i2cHandle);
|
||||
void initalize();
|
||||
uint8_t getOrientation();
|
||||
void getAxisReadings(int16_t *x, int16_t *y, int16_t *z);
|
||||
@@ -21,7 +22,7 @@ private:
|
||||
|
||||
void I2C_RegisterWrite(uint8_t reg, uint8_t data);
|
||||
uint8_t I2C_RegisterRead(uint8_t reg);
|
||||
I2C_HandleTypeDef* i2c;
|
||||
FRToSI2C* i2c;
|
||||
};
|
||||
|
||||
#endif /* LIS2DH12_HPP_ */
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
#define MMA8652FC_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "MMA8652FC_defines.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
class MMA8652FC {
|
||||
|
||||
public:
|
||||
|
||||
MMA8652FC(I2C_HandleTypeDef* i2cHandle);
|
||||
MMA8652FC(FRToSI2C* i2cHandle);
|
||||
void initalize(); // Initalize the system
|
||||
uint8_t getOrientation();// Reads the I2C register and returns the orientation (true == left)
|
||||
void getAxisReadings(int16_t *x, int16_t *y, int16_t *z);
|
||||
@@ -23,7 +24,7 @@ private:
|
||||
|
||||
void I2C_RegisterWrite(uint8_t reg, uint8_t data);
|
||||
uint8_t I2C_RegisterRead(uint8_t reg);
|
||||
I2C_HandleTypeDef* i2c;
|
||||
FRToSI2C* i2c;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <hardware.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdbool.h>
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "Font.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -25,7 +26,7 @@ extern "C" {
|
||||
|
||||
class OLED {
|
||||
public:
|
||||
OLED(I2C_HandleTypeDef* i2cHandle); // Initialize Driver and store I2C pointer
|
||||
OLED(FRToSI2C* i2cHandle); // Initialize Driver and store I2C pointer
|
||||
void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
||||
void refresh(); // Draw the buffer out to the LCD using the DMA Channel
|
||||
void drawChar(char c, char preCursorCommand = '\0');// Draw a character to a specific location
|
||||
@@ -50,7 +51,7 @@ private:
|
||||
|
||||
//Draw a buffer to the screen buffer
|
||||
|
||||
I2C_HandleTypeDef* i2c; //i2c Pointer
|
||||
FRToSI2C* i2c; //i2c Pointer
|
||||
const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer
|
||||
uint8_t screenBuffer[12 + 96 + 96 + 10]; // The data buffer
|
||||
uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||
|
||||
@@ -17,9 +17,10 @@ extern "C" {
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
|
||||
extern DMA_HandleTypeDef hdma_i2c1_rx;
|
||||
extern DMA_HandleTypeDef hdma_i2c1_tx;
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
|
||||
|
||||
extern IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
|
||||
Reference in New Issue
Block a user