SWCU185G January 2018 – June 2024 CC1312PSIP , CC1312R , CC1352P , CC1352R , CC2642R , CC2642R-Q1 , CC2652P , CC2652PSIP , CC2652R , CC2652RB , CC2652RSIP , CC2662R-Q1
The following example in pseudocode describes the actions that are typically executed by the host software. The example starts the Hash engine with a new Hash session that receives the input data through the DMA interface. In the end, the intermediate digest (nonfinal Hash operation) or the finalized Hash digest (final Hash operation) is read as a result digest through the DMA.
// configure master control module
write CTRL_ALG_SEL 0x8000_0008 // enable DMA path to the SHA-512 engine + Digest readout
write CTRL_INT_CLR 0x8000_0001 // clear any outstanding events
// configure hash engine
write HASH_MODE = 0x0000_0021 // indicate the start of a new hash session and SHA512
write HASH_LENGTH_L// write the length of the message (lo)
write HASH_LENGTH_H// write the length of the message (hi)
// if the final digest is required (pad the input DMA data), write the following register
write HASH_IO_BUF_CTRL = 0x80 // pad the data that is transferred via DMA
// configure DMAC
write DMAC_CH0_CTRL 0x0000_00001 // enable DMA channel 0 for message data
write DMAC_CH0_EXTADDR <ext_memory_address>// base address of the data in ext. memory
write DMAC_CH0_DMALENGTH <length> // input data in bytes, equal to the message
// length
write DMAC_CH1_CTRL 0x0000_00001 // enable DMA channel 1 for result digest
write DMAC_CH1_EXTADDR <ext_memory_address>// base address of the digest buffer
write DMAC_CH1_DMALENGTH <length> // length of the result digest
// wait for completion and acknowledge the interrupt
wait CTRL_INT_STAT[0] = '1' // wait for operation done (hash and DMAC are ready)
check CTRL_INT_STAT[31] == '0' // check for the absence of errors
write CTRL_INT_CLR 0x0000_0001 // clear the interrupt
write CTRL_ALG_SEL 0x0000_0000 // disable the master control/DMA clock
// the digest can now be ready from the external memory (see note in section 6.2.3)
// end of algorithm