2 Copyright 2018 Massdrop Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _I2C_MASTER_H_
19 #define _I2C_MASTER_H_
23 #include "samd51j18a.h"
24 #include "issi3733_driver.h"
27 __attribute__((__aligned__(16)))
28 DmacDescriptor dmac_desc;
29 __attribute__((__aligned__(16)))
30 DmacDescriptor dmac_desc_wb;
32 uint8_t I2C3733_Init_Control(void);
33 uint8_t I2C3733_Init_Drivers(void);
34 void I2C3733_Control_Set(uint8_t state);
35 void I2C_DMAC_LED_Init(void);
37 #define I2C_Q_SIZE 100
40 #define I2C_Q_CRWL 101
41 #define I2C_Q_PAGE_SELECT 102
44 #define I2C_Q_ONOFF 105
46 #define I2C_DMA_MAX_SEND 255
48 extern volatile uint8_t i2c_led_q_running;
50 #define I2C_LED_Q_PWM(a) { \
51 if (i2c_led_q_request_room(7)) \
53 i2c_led_q_add(I2C_Q_CRWL); \
55 i2c_led_q_add(I2C_Q_PAGE_SELECT); \
57 i2c_led_q_add(ISSI3733_PG_PWM); \
58 i2c_led_q_add(I2C_Q_PWM); \
63 #define I2C_LED_Q_GCR(a) { \
64 if (i2c_led_q_request_room(7)) \
66 i2c_led_q_add(I2C_Q_CRWL); \
68 i2c_led_q_add(I2C_Q_PAGE_SELECT); \
70 i2c_led_q_add(ISSI3733_PG_FN); \
71 i2c_led_q_add(I2C_Q_GCR); \
76 #define I2C_LED_Q_ONOFF(a) { \
77 if (i2c_led_q_request_room(7)) \
79 i2c_led_q_add(I2C_Q_CRWL); \
81 i2c_led_q_add(I2C_Q_PAGE_SELECT); \
83 i2c_led_q_add(ISSI3733_PG_ONOFF); \
84 i2c_led_q_add(I2C_Q_ONOFF); \
90 void i2c_led_q_init(void);
91 void i2c_led_q_add(uint8_t cmd);
92 void i2c_led_q_s_advance(void);
93 uint8_t i2c_led_q_size(void);
94 uint8_t i2c_led_q_request_room(uint8_t request_size);
95 uint8_t i2c_led_q_run(void);
98 uint8_t i2c1_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout);
101 #endif //MD_BOOTLOADER
103 void i2c0_init(void);
104 uint8_t i2c0_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout);
105 void i2c0_stop(void);
107 #endif // _I2C_MASTER_H_