nPZero IC
API and Examples for the nPZero
Loading...
Searching...
No Matches
np0_hal_read Example

Description

This example demonstrates the usage of the nPZero driver to setup the ADC and there threshould's. Booth ADC's (Internal and External) are set in the example code, the ADC_IN pin for this example is connected to VDD.

Code nPZero HAL read example

Code snippet ...

np0_status_e np0_hal_read(uint8_t slave_address, uint8_t slave_register, uint8_t *pData, uint16_t size, uint32_t timeout)
{
uint8_t transmitData[] = { slave_register};
if (HAL_I2C_Master_Transmit(&m_hi2c1, slave_address, transmitData, sizeof(transmitData), timeout) != HAL_OK)
{
return ERR;
}
HAL_Delay(I2C_DELAY_MS);
if (HAL_I2C_Master_Receive(&m_hi2c1, slave_address, pData, size, timeout) != HAL_OK)
{
return ERR;
}
return OK;
}
np0_status_e
Definition: np0.h:31
@ ERR
Definition: np0.h:33
@ OK
Definition: np0.h:32
#define I2C_DELAY_MS
Definition: np0_hal.c:34
np0_status_e np0_hal_read(uint8_t slave_address, uint8_t slave_register, uint8_t *pData, uint16_t size, uint32_t timeout)
Function to read from registers over I2C.
Definition: np0_hal.c:54

Note

  • Adapt the code to match your MCU throw np0_hal_init.
  • Consult the nPZero driver function documentation for precise function usage.