ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches

CRC hardware calculator driver header. More...

#include <stdint.h>
#include "ra8_crc_regs.h"
#include "ra8_err.h"
Include dependency graph for ra8_crc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ra8_err_t ra8_crc_init (ra8_crc_poly_t poly)
 Configure the CRC block for a given polynomial.
ra8_err_t ra8_crc_compute (const uint8_t *data, uint32_t len, uint32_t *out_crc)
 Compute a CRC over a byte buffer.
void ra8_crc_reset (void)
 Clear the running CRC state.
ra8_err_t ra8_crc_deinit (void)
 Tear down the CRC block (disable + MSTP release).
ra8_err_t ra8_crc_set_poly (ra8_crc_poly_t poly)
 Change the CRC polynomial at runtime without a reset.
ra8_err_t ra8_crc_get_status (uint8_t *out_poly)
 Read the current polynomial selection (CRCCR0.GPS).
ra8_err_t ra8_crc_enter_stop (void)
 Put CRC into MSTP-gated stop.
ra8_err_t ra8_crc_exit_stop (void)
 Exit MSTP-gated stop.

Detailed Description

CRC hardware calculator driver header.

Declares the RA8 CRC engine configuration and bounded byte-stream calculation interface for supported polynomials.

Definition in file ra8_crc.h.

Function Documentation

◆ ra8_crc_compute()

ra8_err_t ra8_crc_compute ( const uint8_t * data,
uint32_t len,
uint32_t * out_crc )
nodiscard

Compute a CRC over a byte buffer.

Feeds each byte of data into CRCDIR and reads the running result from CRCDOR at the end. The CRC unit is not reset between calls – the caller must write CRCCR1 to clear state via ra8_crc_reset() first.

Parameters
[in]dataPointer to bytes (not NULL).
[in]lenByte count.
[out]out_crcReceives the final result.
Returns
ra8_err_t error code.
Since
0.1.0

Definition at line 190 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, r_crc_regs_t::CRCDOR, internal_crc_feed_bytes(), internal_crc_feed_words(), internal_ra8_crc_is_32bit_poly(), k_ra8_crc_32bit_seed, k_ra8_crccr0_gps_mask, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_crc(), and s_tag.

Referenced by crc_demo_one_iter(), and ra8_nsc_crc_compute().

◆ ra8_crc_deinit()

ra8_err_t ra8_crc_deinit ( void )
nodiscard

Tear down the CRC block (disable + MSTP release).

Since
0.1.0

Definition at line 236 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, r_crc_regs_t::CRCCR1, k_ra8_mstp_crc, ra8_crc(), and ra8_mstp_disable().

◆ ra8_crc_enter_stop()

ra8_err_t ra8_crc_enter_stop ( void )
nodiscard

Put CRC into MSTP-gated stop.

Since
0.1.0

Definition at line 264 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, k_ra8_mstp_crc, ra8_crc(), and ra8_mstp_disable().

◆ ra8_crc_exit_stop()

ra8_err_t ra8_crc_exit_stop ( void )
nodiscard

Exit MSTP-gated stop.

Since
0.1.0

Definition at line 271 of file ra8_crc.c.

References k_ra8_mstp_crc, and ra8_mstp_enable().

◆ ra8_crc_get_status()

ra8_err_t ra8_crc_get_status ( uint8_t * out_poly)
nodiscard

Read the current polynomial selection (CRCCR0.GPS).

Since
0.1.0

Definition at line 256 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_crc(), and s_tag.

◆ ra8_crc_init()

ra8_err_t ra8_crc_init ( ra8_crc_poly_t poly)
nodiscard

Configure the CRC block for a given polynomial.

Parameters
[in]polyOne of the k_ra8_crc_poly_* values.
Returns
k_ra8_ok on success.
Since
0.1.0

Definition at line 158 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, r_crc_regs_t::CRCCR1, k_ra8_crccr0_dorclr, k_ra8_mstp_crc, k_ra8_ok, ra8_crc(), ra8_log_info_val, ra8_mstp_enable(), RA8_RETURN_ON_ERROR, and s_tag.

Referenced by crc_demo_setup_or_halt(), and ra8_nsc_crc_init().

◆ ra8_crc_reset()

void ra8_crc_reset ( void )

Clear the running CRC state.

See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.

Precondition
Driver state has been initialized by the matching *_init.
Caller has validated all pointer parameters.
Postcondition
Side effects are limited to those documented in the header.
No global state is modified on the error path.
Note
Thread safety: see the header declaration.
Since
0.1.0

Definition at line 180 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, k_ra8_crccr0_dorclr, and ra8_crc().

Referenced by crc_demo_one_iter().

◆ ra8_crc_set_poly()

ra8_err_t ra8_crc_set_poly ( ra8_crc_poly_t poly)
nodiscard

Change the CRC polynomial at runtime without a reset.

Since
0.1.0

Definition at line 246 of file ra8_crc.c.

References r_crc_regs_t::CRCCR0, k_ra8_crccr0_dorclr, k_ra8_ok, and ra8_crc().