44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
/*
|
|
* bsp_max25512.c
|
|
*
|
|
* Created on: 2025年4月9日
|
|
* Author: 22332
|
|
*/
|
|
#include "../bsp/drv_master_iic.h"
|
|
#include "cola_init.h"
|
|
#include "cola_device.h"
|
|
#include "bsp_register_map.h"
|
|
|
|
static cola_device_t g_max25512_iic;
|
|
|
|
static uint16_t slave_address = MAX25512_Slave_Address;
|
|
|
|
|
|
static int bsp_iic_max25512_write(cola_device_t *dev, int pos, const void *buffer, int size){
|
|
uint8_t *data = (uint8_t *)buffer;
|
|
uint8_t buf[8];
|
|
if(size > 7)
|
|
size = 7;
|
|
buf[0] = (uint8_t)pos;
|
|
for(int i=0; i<size; i++)
|
|
buf[1+i] = (uint8_t)data[i];
|
|
return bsp_ctrl_write_register(slave_address,buf,1+size);
|
|
}
|
|
|
|
static int bsp_iic_max25512_read(cola_device_t *dev, int pos, void *buffer, int size){
|
|
return bsp_ctrl_read_register(slave_address,pos,buffer,size);
|
|
}
|
|
|
|
|
|
static struct cola_device_ops max25512_iic_Ops ={
|
|
.read = bsp_iic_max25512_read,
|
|
.write = bsp_iic_max25512_write,
|
|
};
|
|
|
|
static void bsp_max25512_iic_configuration(void){
|
|
g_max25512_iic.name = "max25512_IIC";
|
|
g_max25512_iic.dops = &max25512_iic_Ops;
|
|
cola_device_register(&g_max25512_iic);
|
|
}
|
|
register_initcall(bsp_max25512_iic_configuration);
|