Commit 63c48bba authored by Dinesh Kumar K's avatar Dinesh Kumar K Committed by Anas Nashif
Browse files

drivers: sensor: grow_r502a: fix in checksum calculation

change checksum calculation to consider 2 bytes in pkg_len.

Signed-off-by: default avatarDinesh Kumar K <dinesh@linumiz.com>
parent 476a3982
Loading
Loading
Loading
Loading
+1 −1
Changes for drivers/sensor/grow_r502a/grow_r502a.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ static void transceive_packet(const struct device *dev, union r502a_packet *tx_p
	uint16_t check_sum, pkg_len;

	pkg_len = data_len + R502A_CHECKSUM_LEN;
	check_sum = pkg_len + tx_packet->pid;
	check_sum = (pkg_len >> 8) + (pkg_len & 0xFF) + tx_packet->pid;

	sys_put_be16(R502A_STARTCODE, tx_packet->start);
	sys_put_be32(cfg->comm_addr, tx_packet->addr);