mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 18:52:30 +00:00
Add scaffolding to read EEPROM data from ch341
This commit is contained in:
committed by
Tom Fifield
parent
b696e083f3
commit
c7dd670e61
37
src/platform/portduino/ch341a_i2c.h
Normal file
37
src/platform/portduino/ch341a_i2c.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// libUSB driver for the ch341a in i2c mode
|
||||
//
|
||||
// Copyright 2011 asbokid <ballymunboy@gmail.com>
|
||||
#ifndef __CH341A_I2C_H__
|
||||
#define __CH341A_I2C_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define BULK_WRITE_ENDPOINT 0x02 /* bEndpointAddress 0x02 EP 2 OUT (Bulk)*/
|
||||
#define BULK_READ_ENDPOINT 0x82 /* bEndpointAddress 0x82 EP 2 IN (Bulk)*/
|
||||
|
||||
#define DEFAULT_TIMEOUT 300 // 300mS for USB timeouts
|
||||
|
||||
#define IN_BUF_SZ 0x100
|
||||
#define EEPROM_READ_BULKIN_BUF_SZ 0x20
|
||||
#define EEPROM_READ_BULKOUT_BUF_SZ 0x65
|
||||
|
||||
#define CH341_CMD_I2C_STREAM 0xAA
|
||||
#define CH341_CMD_I2C_STM_STA 0x74
|
||||
#define CH341_CMD_I2C_STM_STO 0x75
|
||||
#define CH341_CMD_I2C_STM_OUT 0x80
|
||||
#define CH341_CMD_I2C_STM_IN 0xC0
|
||||
#define CH341_CMD_I2C_STM_END 0x00
|
||||
|
||||
#define CH341_EEPROM_READ_CMD_SZ 0x65 /* Same size for all 24cXX read setup and next packets*/
|
||||
|
||||
struct EEPROM {
|
||||
char *name;
|
||||
uint32_t size;
|
||||
uint16_t page_size;
|
||||
uint8_t addr_size; // Length of addres in bytes
|
||||
uint8_t i2c_addr_mask;
|
||||
};
|
||||
|
||||
int32_t ch341readEEPROM_param(uint8_t *buffer, uint32_t offset, uint32_t bytestoread, uint32_t ic_size, uint32_t block_size,
|
||||
uint8_t algorithm, uint32_t i2c_address, struct libusb_device_handle *handle);
|
||||
#endif /* __CH341A_I2C_H__ */
|
||||
Reference in New Issue
Block a user