1
0
forked from me/IronOS
This commit is contained in:
Ben V. Brown
2020-06-17 18:14:17 +10:00
parent 4c2fb11d32
commit 6d23617670
5 changed files with 61 additions and 53 deletions

View File

@@ -13,7 +13,7 @@
#define SDA_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
#define SDA_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port,SDA2_Pin)==GPIO_PIN_SET?1:0)
#define SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port,SCL2_Pin)==GPIO_PIN_SET?1:0)
#define I2C_DELAY() {for(int xx=0;xx<700;xx++){asm("nop");}}
#define I2C_DELAY() {for(int xx=0;xx<100;xx++){asm("nop");}}
SemaphoreHandle_t I2CBB::I2CSemaphore = NULL;
StaticSemaphore_t I2CBB::xSemaphoreBuffer;
void I2CBB::init() {
@@ -269,7 +269,11 @@ bool I2CBB::lock() {
if (I2CSemaphore == NULL) {
asm("bkpt");
}
return xSemaphoreTake(I2CSemaphore, (TickType_t) 50) == pdTRUE;
bool a = xSemaphoreTake(I2CSemaphore, (TickType_t) 50) == pdTRUE;
if (!a) {
asm("bkpt");
}
return a;
}
void I2CBB::write_bit(uint8_t val) {

View File

@@ -6,6 +6,7 @@
*/
#include "IRQ.h"
#include "int_n.h"
/*
* Catch the IRQ that says that the conversion is done on the temperature
* readings coming in Once these have come in we can unblock the PID so that it
@@ -41,3 +42,7 @@ void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
FRToSI2C::CpltCallback();
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
InterruptHandler::irqCallback();
}

View File

@@ -24,6 +24,7 @@ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
void HAL_GPIO_EXTI_Callback(uint16_t);
#ifdef __cplusplus
}