Prusa MINI Firmware overview
st25dv64k.h File Reference
#include <inttypes.h>

Go to the source code of this file.

Functions

void st25dv64k_init (void)
 
uint8_t st25dv64k_user_read (uint16_t address)
 
void st25dv64k_user_write (uint16_t address, uint8_t data)
 
void st25dv64k_user_read_bytes (uint16_t address, void *pdata, uint8_t size)
 
void st25dv64k_user_write_bytes (uint16_t address, void *pdata, uint8_t size)
 
uint8_t st25dv64k_rd_cfg (uint16_t address)
 
void st25dv64k_wr_cfg (uint16_t address, uint8_t data)
 
void st25dv64k_present_pwd (uint8_t *pwd)
 

Function Documentation

◆ st25dv64k_init()

void st25dv64k_init ( void  )
73  {
74  uint8_t pwd[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
75  if (!st25dv64k_initialised) {
76  if ((st25dv64k_rd_cfg(REG_ENDA1) != 0x7f)
77  && (st25dv64k_rd_cfg(REG_ENDA2) != 0xff)
78  && (st25dv64k_rd_cfg(REG_ENDA3) != 0xff)) {
84 
88  }
90  }
91 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_user_read()

uint8_t st25dv64k_user_read ( uint16_t  address)
93  {
94  uint8_t _out[2] = { address >> 8, address & 0xff };
95  uint8_t data;
100  return data;
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_user_write()

void st25dv64k_user_write ( uint16_t  address,
uint8_t  data 
)
103  {
104  uint8_t _out[3] = { address >> 8, address & 0xff, data };
105  st25dv64k_lock();
108  st25dv64k_unlock(); // unlock must be here because other threads cannot access eeprom while writing/waiting
109 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_user_read_bytes()

void st25dv64k_user_read_bytes ( uint16_t  address,
void pdata,
uint8_t  size 
)
111  {
112  uint8_t _out[2] = { address >> 8, address & 0xff };
113  st25dv64k_lock();
117 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_user_write_bytes()

void st25dv64k_user_write_bytes ( uint16_t  address,
void pdata,
uint8_t  size 
)
119  {
120  uint8_t *p = (uint8_t *)pdata;
121  uint8_t _out[6];
122  uint8_t block_size;
123  st25dv64k_lock();
124  while (size) {
125  block_size = BLOCK_BYTES - (address % BLOCK_BYTES);
126  if (block_size > size)
127  block_size = size;
128  _out[0] = address >> 8;
129  _out[1] = address & 0xff;
130  memcpy(_out + 2, p, block_size);
131  HAL_I2C_Master_Transmit(&hi2c1, ADDR_WRITE, _out, 2 + block_size, HAL_MAX_DELAY);
133  size -= block_size;
134  address += block_size;
135  p += block_size;
136  }
137  st25dv64k_unlock(); // unlock must be here because other threads cannot access eeprom while writing/waiting
138 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_rd_cfg()

uint8_t st25dv64k_rd_cfg ( uint16_t  address)
140  {
141  uint8_t _out[2] = { address >> 8, address & 0xff };
142  uint8_t data;
143  st25dv64k_lock();
147  return data;
148 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_wr_cfg()

void st25dv64k_wr_cfg ( uint16_t  address,
uint8_t  data 
)
150  {
151  uint8_t _out[3] = { address >> 8, address & 0xff, data };
152  st25dv64k_lock();
155  st25dv64k_unlock(); // unlock must be here because other threads cannot access eeprom while writing/waiting
156 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st25dv64k_present_pwd()

void st25dv64k_present_pwd ( uint8_t pwd)
158  {
159  uint8_t _out[19] = { 0x09, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0x09, 0, 0, 0, 0, 0, 0, 0, 0 };
160  if (pwd) {
161  memcpy(_out + 2, pwd, 8);
162  memcpy(_out + 11, pwd, 8);
163  }
164  st25dv64k_lock();
167 }
Here is the call graph for this function:
Here is the caller graph for this function:
ADDR_READ
#define ADDR_READ
Definition: st25dv64k.c:31
BLOCK_DELAY
#define BLOCK_DELAY
Definition: st25dv64k.c:35
st25dv64k_rd_cfg
uint8_t st25dv64k_rd_cfg(uint16_t address)
Definition: st25dv64k.c:140
DELAY
#define DELAY
Definition: st25dv64k.c:38
data
uint8_t data[8]
Definition: masstorage.h:49
st25dv64k_wr_cfg
void st25dv64k_wr_cfg(uint16_t address, uint8_t data)
Definition: st25dv64k.c:150
REG_ENDA3
#define REG_ENDA3
Definition: st25dv64k.c:21
st25dv64k_present_pwd
void st25dv64k_present_pwd(uint8_t *pwd)
Definition: st25dv64k.c:158
auto_build.pwd
pwd
Definition: auto_build.py:78
st25dv64k_unlock
static void st25dv64k_unlock(void)
Definition: st25dv64k.c:57
REG_ENDA1
#define REG_ENDA1
Definition: st25dv64k.c:17
st25dv64k_lock
static void st25dv64k_lock(void)
Definition: st25dv64k.c:49
ADDR_READ_SYS
#define ADDR_READ_SYS
Definition: st25dv64k.c:33
uint8_t
const uint8_t[]
Definition: 404_html.c:3
address
UsbDeviceAddress address
Definition: address.h:202
HAL_I2C_Master_Transmit
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
st25dv64k_initialised
uint8_t st25dv64k_initialised
Definition: st25dv64k.c:42
hi2c1
I2C_HandleTypeDef hi2c1
Definition: main.c:77
BLOCK_BYTES
#define BLOCK_BYTES
Definition: st25dv64k.c:36
ADDR_WRITE_SYS
#define ADDR_WRITE_SYS
Definition: st25dv64k.c:32
HAL_I2C_Master_Receive
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
REG_ENDA2
#define REG_ENDA2
Definition: st25dv64k.c:19
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f4xx_hal_def.h:76
ADDR_WRITE
#define ADDR_WRITE
Definition: st25dv64k.c:30
size
static png_bytep size_t size
Definition: pngwrite.c:2170