YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
i2c_rp2350.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_RP2350_H_
19#define _I2C_RP2350_H_
20
21#include "i2c_interface.h"
22#include "gpio_rp2350.h"
23
24#include "RP2350.h"
25using namespace _I2C0_;
26
27class i2c_rp2350 : public i2c_interface {
28
29public:
30
31 i2c_rp2350(gpio_pin_t sda_pin,
32 gpio_pin_t scl_pin,
33 uint16_t mode);
34
35 ~i2c_rp2350() override;
36
37 int16_t i2cRead (uint16_t addr, uint8_t *rxbuf,
38 uint16_t len, bool sendStop) override;
39 int16_t i2cWrite(uint16_t addr, uint8_t *txbuf,
40 uint16_t len, bool sendStop) override;
41
42 void setSpeed(uint32_t) override;
43
44private:
45 bool _initialized;
46 void initialize();
47
48 int _index;
49 gpio_rp2350 _sda;
50 gpio_rp2350 _scl;
51
52// bool _master;
53 uint16_t _mode;
54 bool _restart_on_next;
55
56 I2C0_t * _i2c;
57 I2C0_t * _i2c_set;
58 I2C0_t * _i2c_clr;
59};
60
61#endif // _I2C_RP2350_H_