IoAbstraction
Toggle main menu visibility
Loading...
Searching...
No Matches
src
PlatformDeterminationWire.h
1
/*
2
* Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3
* This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4
*/
5
6
#ifndef IOA_PLATFORMDETERMINATIONWIRE_H
7
#define IOA_PLATFORMDETERMINATIONWIRE_H
8
9
#include "PlatformDetermination.h"
10
#include <SimpleSpinLock.h>
11
12
//
13
// Here we work out what wire looks like on this board! Becoming non trivial these days!
14
//
15
#ifdef IOA_USE_MBED
16
#include <i2c_api.h>
17
typedef
I2C* WireType;
18
void
ioaWireBegin(I2C* pI2cToUse);
19
# define IOA_USE_MBED_WIRE
20
#elif defined(IOA_USE_AVR_TWI_DIRECT) && defined(__AVR__) && defined(IOA_DEVELOPMENT_EXPERIMENTAL)
21
class
AvrTwiManager;
22
typedef
AvrTwiManager* WireType;
23
extern
WireType AvrTwi;
24
void
ioaWireBegin();
25
#elif defined(BUILD_FOR_PICO_CMAKE)
26
#define IOA_USE_PICOSDK_I2C
27
#include "pico/i2cWrapper.h"
28
class
PicoI2cWrapper;
29
typedef
PicoI2cWrapper* WireType;
30
void
ioaWireBegin(i2c_inst_t* toUse);
31
#else
32
# define IOA_USE_ARDUINO_WIRE
33
#include <Wire.h>
34
typedef
TwoWire* WireType;
35
void
ioaWireBegin();
36
#endif
// IOA_USE_MBED
37
38
extern
WireType defaultWireTypePtr;
39
47
bool
ioaWireRead(WireType wire,
int
address, uint8_t* buffer,
size_t
len);
48
61
bool
ioaWireWriteWithRetry(WireType pI2c,
int
address,
const
uint8_t* buffer,
size_t
len,
int
retriesAllowed = 0,
bool
sendStop =
true
);
62
68
void
ioaWireSetSpeed(WireType pI2c,
long
frequency);
69
75
bool
ioaWireReady(WireType wire,
int
address);
76
81
extern
SimpleSpinLock i2cLock;
82
83
#endif
//IOA_PLATFORMDETERMINATIONWIRE_H