at32f413_crc.h 4.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
/**
  **************************************************************************
  * @file     at32f413_crc.h
  * @version  v2.0.4
  * @date     2022-04-02
  * @brief    at32f413 crc header file
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __AT32F413_CRC_H
#define __AT32F413_CRC_H

#ifdef __cplusplus
extern "C" {
#endif


/* includes ------------------------------------------------------------------*/
#include "at32f413.h"

/** @addtogroup AT32F413_periph_driver
  * @{
  */

/** @addtogroup  CRC
  * @{
  */

/** @defgroup CRC_exported_types
  * @{
  */

/**
  * @brief crc reverse input data
  */
typedef enum
{
  CRC_REVERSE_INPUT_NO_AFFECTE           = 0x00, /*!< input data no reverse */
  CRC_REVERSE_INPUT_BY_BYTE              = 0x01, /*!< input data reverse by byte */
  CRC_REVERSE_INPUT_BY_HALFWORD          = 0x02, /*!< input data reverse by half word */
  CRC_REVERSE_INPUT_BY_WORD              = 0x03  /*!< input data reverse by word */
} crc_reverse_input_type;

/**
  * @brief crc reverse output data
  */
typedef enum
{
  CRC_REVERSE_OUTPUT_NO_AFFECTE          = 0x00, /*!< output data no reverse */
  CRC_REVERSE_OUTPUT_DATA                = 0x01  /*!< output data reverse by word */
} crc_reverse_output_type;

/**
 * @brief type define crc register all
 */
typedef struct
{
  /**
    * @brief crc dt register, offset:0x00
    */
  union
  {
    __IO uint32_t dt;
    struct
    {
      __IO uint32_t dt                   : 32; /* [31:0] */
    } dt_bit;
  };

  /**
    * @brief crc cdt register, offset:0x04
    */
  union
  {
    __IO uint32_t cdt;
    struct
    {
      __IO uint32_t cdt                  : 8 ; /* [7:0] */
      __IO uint32_t reserved1            : 24 ;/* [31:8] */
    } cdt_bit;
  };

  /**
    * @brief crc ctrl register, offset:0x08
    */
  union
  {
    __IO uint32_t ctrl;
    struct
    {
      __IO uint32_t rst                  : 1 ; /* [0] */
      __IO uint32_t reserved1            : 4 ; /* [4:1] */
      __IO uint32_t revid                : 2 ; /* [6:5] */
      __IO uint32_t revod                : 1 ; /* [7] */
      __IO uint32_t reserved2            : 24 ;/* [31:8] */
    } ctrl_bit;
  };

  /**
    * @brief crm reserved1 register, offset:0x0C
    */
  __IO uint32_t reserved1;

  /**
    * @brief crc idt register, offset:0x10
    */
  union
  {
    __IO uint32_t idt;
    struct
    {
      __IO uint32_t idt                  : 32; /* [31:0] */
    } idt_bit;
  };

} crc_type;

/**
  * @}
  */

#define CRC                              ((crc_type *) CRC_BASE)

/** @defgroup CRC_exported_functions
  * @{
  */

void crc_data_reset(void);
uint32_t crc_one_word_calculate(uint32_t data);
uint32_t crc_block_calculate(uint32_t *pbuffer, uint32_t length);
uint32_t crc_data_get(void);
void crc_common_data_set(uint8_t cdt_value);
uint8_t crc_common_date_get(void);
void crc_init_data_set(uint32_t value);
void crc_reverse_input_data_set(crc_reverse_input_type value);
void crc_reverse_output_data_set(crc_reverse_output_type value);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif