|
1 |
| -/*! |
2 |
| - \file gd32f30x_crc.h |
3 |
| - \brief definitions for the CRC |
4 |
| -
|
5 |
| - \version 2018-10-10, V1.1.0, firmware for GD32F30x (The version is for mbed) |
6 |
| -*/ |
7 |
| - |
8 |
| -/* |
9 |
| - Copyright (c) 2018, GigaDevice Semiconductor Inc. |
10 |
| -
|
11 |
| - All rights reserved. |
12 |
| -
|
13 |
| - Redistribution and use in source and binary forms, with or without modification, |
14 |
| -are permitted provided that the following conditions are met: |
15 |
| -
|
16 |
| - 1. Redistributions of source code must retain the above copyright notice, this |
17 |
| - list of conditions and the following disclaimer. |
18 |
| - 2. Redistributions in binary form must reproduce the above copyright notice, |
19 |
| - this list of conditions and the following disclaimer in the documentation |
20 |
| - and/or other materials provided with the distribution. |
21 |
| - 3. Neither the name of the copyright holder nor the names of its contributors |
22 |
| - may be used to endorse or promote products derived from this software without |
23 |
| - specific prior written permission. |
24 |
| -
|
25 |
| - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
26 |
| -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
27 |
| -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
28 |
| -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
29 |
| -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
30 |
| -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
31 |
| -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
32 |
| -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
33 |
| -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
34 |
| -OF SUCH DAMAGE. |
35 |
| -*/ |
36 |
| - |
37 |
| -#ifndef GD32F30X_CRC_H |
38 |
| -#define GD32F30X_CRC_H |
39 |
| - |
40 |
| -#include "gd32f30x.h" |
41 |
| - |
42 |
| -/* CRC definitions */ |
43 |
| -#define CRC CRC_BASE |
44 |
| - |
45 |
| -/* registers definitions */ |
46 |
| -#define CRC_DATA REG32(CRC + 0x00U) /*!< CRC data register */ |
47 |
| -#define CRC_FDATA REG32(CRC + 0x04U) /*!< CRC free data register */ |
48 |
| -#define CRC_CTL REG32(CRC + 0x08U) /*!< CRC control register */ |
49 |
| - |
50 |
| -/* bits definitions */ |
51 |
| -/* CRC_DATA */ |
52 |
| -#define CRC_DATA_DATA BITS(0,31) /*!< CRC calculation result bits */ |
53 |
| - |
54 |
| -/* CRC_FDATA */ |
55 |
| -#define CRC_FDATA_FDATA BITS(0,7) /*!< CRC free data bits */ |
56 |
| - |
57 |
| -/* CRC_CTL */ |
58 |
| -#define CRC_CTL_RST BIT(0) /*!< CRC reset CRC_DATA register bit */ |
59 |
| - |
60 |
| - |
61 |
| -/* function declarations */ |
62 |
| -/* deinit CRC calculation unit */ |
63 |
| -void crc_deinit(void); |
64 |
| - |
65 |
| -/* reset data register to the value of initializaiton data register */ |
66 |
| -void crc_data_register_reset(void); |
67 |
| -/* read the data register */ |
68 |
| -uint32_t crc_data_register_read(void); |
69 |
| - |
70 |
| -/* read the free data register */ |
71 |
| -uint8_t crc_free_data_register_read(void); |
72 |
| -/* write the free data register */ |
73 |
| -void crc_free_data_register_write(uint8_t free_data); |
74 |
| - |
75 |
| -/* CRC calculate a 32-bit data */ |
76 |
| -uint32_t crc_single_data_calculate(uint32_t sdata); |
77 |
| -/* CRC calculate a 32-bit data array */ |
78 |
| -uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size); |
79 |
| - |
80 |
| -#endif /* GD32F30X_CRC_H */ |
| 1 | +/*! |
| 2 | + \file gd32f30x_crc.h |
| 3 | + \brief definitions for the CRC |
| 4 | +
|
| 5 | + \version 2018-10-10, V1.1.0, firmware for GD32F30x (The version is for mbed) |
| 6 | +*/ |
| 7 | + |
| 8 | +/* |
| 9 | + Copyright (c) 2018, GigaDevice Semiconductor Inc. |
| 10 | +
|
| 11 | + All rights reserved. |
| 12 | +
|
| 13 | + Redistribution and use in source and binary forms, with or without modification, |
| 14 | +are permitted provided that the following conditions are met: |
| 15 | +
|
| 16 | + 1. Redistributions of source code must retain the above copyright notice, this |
| 17 | + list of conditions and the following disclaimer. |
| 18 | + 2. Redistributions in binary form must reproduce the above copyright notice, |
| 19 | + this list of conditions and the following disclaimer in the documentation |
| 20 | + and/or other materials provided with the distribution. |
| 21 | + 3. Neither the name of the copyright holder nor the names of its contributors |
| 22 | + may be used to endorse or promote products derived from this software without |
| 23 | + specific prior written permission. |
| 24 | +
|
| 25 | + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 26 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 27 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 28 | +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 29 | +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 30 | +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 31 | +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 32 | +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
| 34 | +OF SUCH DAMAGE. |
| 35 | +*/ |
| 36 | + |
| 37 | +#ifndef GD32F30X_CRC_H |
| 38 | +#define GD32F30X_CRC_H |
| 39 | + |
| 40 | +#include "gd32f30x.h" |
| 41 | + |
| 42 | +/* CRC definitions */ |
| 43 | +#define CRC CRC_BASE |
| 44 | + |
| 45 | +/* registers definitions */ |
| 46 | +#define CRC_DATA REG32(CRC + 0x00U) /*!< CRC data register */ |
| 47 | +#define CRC_FDATA REG32(CRC + 0x04U) /*!< CRC free data register */ |
| 48 | +#define CRC_CTL REG32(CRC + 0x08U) /*!< CRC control register */ |
| 49 | + |
| 50 | +/* bits definitions */ |
| 51 | +/* CRC_DATA */ |
| 52 | +#define CRC_DATA_DATA BITS(0,31) /*!< CRC calculation result bits */ |
| 53 | + |
| 54 | +/* CRC_FDATA */ |
| 55 | +#define CRC_FDATA_FDATA BITS(0,7) /*!< CRC free data bits */ |
| 56 | + |
| 57 | +/* CRC_CTL */ |
| 58 | +#define CRC_CTL_RST BIT(0) /*!< CRC reset CRC_DATA register bit */ |
| 59 | + |
| 60 | + |
| 61 | +/* function declarations */ |
| 62 | +/* deinit CRC calculation unit */ |
| 63 | +void crc_deinit(void); |
| 64 | + |
| 65 | +/* reset data register to the value of initializaiton data register */ |
| 66 | +void crc_data_register_reset(void); |
| 67 | +/* read the data register */ |
| 68 | +uint32_t crc_data_register_read(void); |
| 69 | + |
| 70 | +/* read the free data register */ |
| 71 | +uint8_t crc_free_data_register_read(void); |
| 72 | +/* write the free data register */ |
| 73 | +void crc_free_data_register_write(uint8_t free_data); |
| 74 | + |
| 75 | +/* CRC calculate a 32-bit data */ |
| 76 | +uint32_t crc_single_data_calculate(uint32_t sdata); |
| 77 | +/* CRC calculate a 32-bit data array */ |
| 78 | +uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size); |
| 79 | + |
| 80 | +#endif /* GD32F30X_CRC_H */ |
0 commit comments