SWCU194 March 2023 CC1314R10 , CC1354P10 , CC1354R10 , CC2674P10 , CC2674R10
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 ALGSEL 0x80000008 // enable DMA path to the SHA-512 engine + Digest readout
write IRQCLR 0x80000001 // clear any outstanding events
// configure hash engine
write HASHMODE = 0x00000021 // indicate the start of a new hash session and SHA512
write HASHINLENL // write the length of the message (lo)
write HASHINLENH // write the length of the message (hi)
// if the final digest is required (pad the input DMA data), write the following register
write HASHIOBUFCTRL = 0x80 // pad the data that is transferred via DMA
// configure DMAC
write DMACH0CTL 0x000000001 // enable DMA channel 0 for message data
write DMACH0EXTADDR <ext_memory_address> // base address of the data in ext. memory
write DMACH0LEN <length> // input data in bytes, equal to the message length
write DMACH1CTL 0x000000001 // enable DMA channel 1 for result digest
write DMACH1EXTADDR <ext_memory_address> // base address of the digest buffer
write DMACH1LEN <length> // length of the result digest
// wait for completion and acknowledge the interrupt
wait IRQSTAT[0] = '1' // wait for operation done (hash and DMAC are ready)
check IRQSTAT[31] == '0' // check for the absence of errors
write IRQCLR 0x00000001 // clear the interrupt
write ALGSEL 0x00000000 // disable the master control/DMA clock
// the digest can now be ready from the external memory
// end of algorithm