Close

More STC3100

A project log for LoRaWAN Feather

An Adafruit-compatible, LoRaWAN-compatible board.

AndyAndy 12/15/2019 at 19:480 Comments

Now onto the STC3100_Read method:

int STC3100_Read(unsigned char ByteCount, unsigned char RegisterAddr , unsigned char * RxBuffer)
{
	HAL_StatusTypeDef halRet = HAL_OK;

	if(!RxBuffer)
	{
		return( halRet = HAL_ERROR);
	}

	halRet = HAL_I2C_Master_Transmit(&hi2c3, STC3100_SLAVE_ADDRESS_8BIT, &RegisterAddr, 1, HAL_MAX_DELAY);

	if(halRet != HAL_OK)
	{
		return halRet;
	}

	halRet = HAL_I2C_Master_Receive(&hi2c3, STC3100_SLAVE_ADDRESS_8BIT, RxBuffer, ByteCount, HAL_MAX_DELAY);

	if(halRet != HAL_OK)
	{
		return halRet;
	}

	return halRet;
}

Pretty simple and straightforward stuff.

The code works on the Charger 2 Click and I get back readings that seem to look just fine.  Now onto adapting it run on the LoRaWAN Feather board.

Discussions