Correct the transmit protocol for Nordic TWI. (#417)

* Correct the transmit protocol for Nordic TWI.
The register address and the data must be sent in one operation, as
specified in the nRF51 Series Reference Manual version 3.0.

  * arch/ARM/Nordic/drivers/nrf_common/nrf-twi.adb:
    (Master_Transmit): Clear any previous Suspend/Stop settings before
      the transfer.
      Only do a Stop_Sequence if requested.
    (Mem_Write): Call Master_Transmit to send the data as well as the
      register address in one transaction. This requires moving the
      Do_Stop_Sequence setting to before this single transaction.

* Revert Nordic TWI Mem_Write to original.

Avoids creating a potentially large data buffer on the stack.

  * arch/ARM/Nordic/drivers/nrf_common/nrf-twi.adb (Mem_Write): reverted to
      sending the register address without a stop sequence, followed by the
      data, followed by a stop sequence.
This commit is contained in:
Simon Wright 2022-12-05 15:19:36 +00:00 committed by GitHub
parent 647eac212a
commit bbdc182bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016-2020, AdaCore --
-- Copyright (C) 2016-2022, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
@ -134,6 +134,11 @@ package body nRF.TWI is
-- Set Address
This.Periph.ADDRESS.ADDRESS := UInt7 (Addr / 2);
-- Configure SHORTS to neither suspend nor stop the TWI port
-- after the next byte transfer.
This.Periph.SHORTS.BB_SUSPEND := Disabled;
This.Periph.SHORTS.BB_STOP := Disabled;
-- Prepare first byte
This.Periph.TXD.TXD := Data (Data'First);
@ -201,7 +206,6 @@ package body nRF.TWI is
-- Set Address
This.Periph.ADDRESS.ADDRESS := UInt7 (Addr / 2);
if Data'Length = 1 then
-- Only one byte to receive so we stop at the next one
This.Periph.SHORTS.BB_STOP := Enabled;