YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
i2c_rp2040.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14// I2C driver for RP2040. It support master
15// and client mode. Interrupts are supported
16// for client mode (RX interrupts).
17//
18#ifndef _I2C_RP2040_H_
19#define _I2C_RP2040_H_
20
21#include "i2c_interface.h"
22#include "gpio_rp2040.h"
23#include "RP2040.h"
24
25using namespace _I2C0_;
26using namespace _I2C1_;
27
28class i2c_rp2040 : public i2c_interface {
29
30public:
31
32 i2c_rp2040(uint8_t index,
33 gpio_pin_t sda_pin,
34 gpio_pin_t scl_pin,
35 uint16_t mode);
36
38
39 int16_t i2cRead (uint16_t addr, uint8_t *rxbuf,
40 uint16_t len, bool sendStop=true) override;
41 int16_t i2cWrite(uint16_t addr, uint8_t *txbuf,
42 uint16_t len, bool sendStop=true) override;
43
44 void setSpeed(uint32_t) override;
45
46private:
47 bool _initialized;
48 void initialize();
49
50 int _index;
51 gpio_rp2040 _sda;
52 gpio_rp2040 _scl;
53
54// bool _master;
55 uint16_t _mode;
56 bool _restart_on_next;
57
58 I2C0_t * _i2c;
59 I2C0_t * _i2c_set;
60 I2C0_t * _i2c_clr;
61};
62
63#endif // _I2C_RP2040_H_
CMSIS-Core(M) Device Peripheral Access Layer Header File for Device RP2040.