mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 14:33:07 +01:00
intermediate: add iic task
This commit is contained in:
27
lib/iictask/GwIicTask.cpp
Normal file
27
lib/iictask/GwIicTask.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//#ifdef _GWIIC
|
||||
#include "GwIicTask.h"
|
||||
#include "GwHardware.h"
|
||||
#include <Wire.h>
|
||||
void runIicTask(GwApi *api){
|
||||
GwLog *logger=api->getLogger();
|
||||
#ifndef _GWIIC
|
||||
LOG_DEBUG(GwLog::LOG,"no iic defined, iic task stopped");
|
||||
vTaskDelete(NULL);
|
||||
return;
|
||||
#endif
|
||||
#ifndef GWIIC_SDA
|
||||
#define GWIIC_SDA -1
|
||||
#endif
|
||||
#ifndef GWIIC_SCL
|
||||
#define GWIIC_SCL -1
|
||||
#endif
|
||||
LOG_DEBUG(GwLog::LOG,"iic task started");
|
||||
bool rt=Wire.begin(GWIIC_SDA,GWIIC_SCL);
|
||||
if (! rt){
|
||||
LOG_DEBUG(GwLog::ERROR,"unable to initialize IIC");
|
||||
vTaskDelete(NULL);
|
||||
return;
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
//#endif
|
||||
5
lib/iictask/GwIicTask.h
Normal file
5
lib/iictask/GwIicTask.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifndef _GWIICTASK
|
||||
#define _GWIICTASK
|
||||
#include "GwApi.h"
|
||||
DECLARE_USERTASK(runIicTask)
|
||||
#endif
|
||||
Reference in New Issue
Block a user