Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches

This section group all the functions concerning serial interface management. More...

Collaboration diagram for "Serial Interface":

Modules

 STM32H7xx SPI Platform Specific Functions
 Functions to connect LIS2MDL driver to STM32H7xx SPI HAL.
 

Functions

int32_t lis2mdl_spi_mode_set (const stmdev_ctx_t *ctx, lis2mdl_sim_t val)
 SPI Serial Interface Mode selection.[set].
 
int32_t lis2mdl_spi_mode_get (const stmdev_ctx_t *ctx, lis2mdl_sim_t *val)
 SPI Serial Interface Mode selection.[get].
 
int32_t lis2mdl_i2c_interface_set (const stmdev_ctx_t *ctx, lis2mdl_i2c_dis_t val)
 Enable/Disable I2C interface.[set].
 
int32_t lis2mdl_i2c_interface_get (const stmdev_ctx_t *ctx, lis2mdl_i2c_dis_t *val)
 Enable/Disable I2C interface.[get].
 

Detailed Description

This section group all the functions concerning serial interface management.

Function Documentation

◆ lis2mdl_i2c_interface_get()

int32_t lis2mdl_i2c_interface_get ( const stmdev_ctx_t ctx,
lis2mdl_i2c_dis_t val 
)

Enable/Disable I2C interface.[get].

Parameters
ctxread / write interface definitions.(ptr)
valGet the values of i2c_dis in reg CFG_REG_C.(ptr)
Return values
interfacestatus.(MANDATORY: return 0 -> no Error)

Definition at line 1332 of file lis2mdl_reg.c.

1334{
1336 int32_t ret;
1337
1338 ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1339
1340 switch (reg.i2c_dis)
1341 {
1342 case LIS2MDL_I2C_ENABLE:
1343 *val = LIS2MDL_I2C_ENABLE;
1344 break;
1345
1347 *val = LIS2MDL_I2C_DISABLE;
1348 break;
1349
1350 default:
1351 *val = LIS2MDL_I2C_ENABLE;
1352 break;
1353 }
1354
1355 return ret;
1356}
int32_t __weak lis2mdl_read_reg(const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
Read generic device register.
Definition lis2mdl_reg.c:66
#define LIS2MDL_CFG_REG_C
@ LIS2MDL_I2C_ENABLE
@ LIS2MDL_I2C_DISABLE

References lis2mdl_cfg_reg_c_t::i2c_dis, LIS2MDL_CFG_REG_C, LIS2MDL_I2C_DISABLE, LIS2MDL_I2C_ENABLE, and lis2mdl_read_reg().

Here is the call graph for this function:

◆ lis2mdl_i2c_interface_set()

int32_t lis2mdl_i2c_interface_set ( const stmdev_ctx_t ctx,
lis2mdl_i2c_dis_t  val 
)

Enable/Disable I2C interface.[set].

Parameters
ctxread / write interface definitions.(ptr)
valchange the values of i2c_dis in reg CFG_REG_C
Return values
interfacestatus.(MANDATORY: return 0 -> no Error)

Definition at line 1307 of file lis2mdl_reg.c.

1309{
1311 int32_t ret;
1312
1313 ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1314
1315 if (ret == 0)
1316 {
1317 reg.i2c_dis = (uint8_t)val;
1318 ret = lis2mdl_write_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1319 }
1320
1321 return ret;
1322}
int32_t __weak lis2mdl_write_reg(const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
Write generic device register.
Definition lis2mdl_reg.c:92

References lis2mdl_cfg_reg_c_t::i2c_dis, LIS2MDL_CFG_REG_C, lis2mdl_read_reg(), and lis2mdl_write_reg().

Here is the call graph for this function:

◆ lis2mdl_spi_mode_get()

int32_t lis2mdl_spi_mode_get ( const stmdev_ctx_t ctx,
lis2mdl_sim_t val 
)

SPI Serial Interface Mode selection.[get].

Parameters
ctxread / write interface definitions
valGet the values of 4wspi in reg CFG_REG_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1274 of file lis2mdl_reg.c.

1275{
1277 int32_t ret;
1278
1279 ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1280
1281 switch (reg._4wspi)
1282 {
1283 case LIS2MDL_SPI_4_WIRE:
1284 *val = LIS2MDL_SPI_4_WIRE;
1285 break;
1286
1287 case LIS2MDL_SPI_3_WIRE:
1288 *val = LIS2MDL_SPI_3_WIRE;
1289 break;
1290
1291 default:
1292 *val = LIS2MDL_SPI_3_WIRE;
1293 break;
1294 }
1295
1296 return ret;
1297}
@ LIS2MDL_SPI_3_WIRE
@ LIS2MDL_SPI_4_WIRE

References lis2mdl_cfg_reg_c_t::_4wspi, LIS2MDL_CFG_REG_C, lis2mdl_read_reg(), LIS2MDL_SPI_3_WIRE, and LIS2MDL_SPI_4_WIRE.

Here is the call graph for this function:

◆ lis2mdl_spi_mode_set()

int32_t lis2mdl_spi_mode_set ( const stmdev_ctx_t ctx,
lis2mdl_sim_t  val 
)

SPI Serial Interface Mode selection.[set].

Parameters
ctxread / write interface definitions
valchange the values of 4wspi in reg CFG_REG_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1250 of file lis2mdl_reg.c.

1251{
1253 int32_t ret;
1254
1255 ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1256
1257 if (ret == 0)
1258 {
1259 reg._4wspi = (uint8_t)val;
1260 ret = lis2mdl_write_reg(ctx, LIS2MDL_CFG_REG_C, (uint8_t *)&reg, 1);
1261 }
1262
1263 return ret;
1264}

References lis2mdl_cfg_reg_c_t::_4wspi, LIS2MDL_CFG_REG_C, lis2mdl_read_reg(), and lis2mdl_write_reg().

Referenced by lis2mdl_init(), and lis2mdl_init_2().

Here is the call graph for this function:
Here is the caller graph for this function: