main.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*!
  2. \file main.c
  3. \brief CRC calculate demo
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #include "gd32f3x0.h"
  10. #include "systick.h"
  11. #include <stdio.h>
  12. #include "gd32f3x0_eval.h"
  13. uint32_t vab1 = 0, success_flag = 0;
  14. uint32_t read32_1, read32_2, read32_3, read32_4, read32_5, read32_6, read32_7, read32_8;
  15. /*!
  16. \brief main function
  17. \param[in] none
  18. \param[out] none
  19. \retval none
  20. */
  21. int main(void)
  22. {
  23. gd_eval_led_init(LED1);
  24. vab1 = (uint32_t)0xabcd1234;
  25. rcu_periph_clock_enable(RCU_CRC);
  26. crc_deinit();
  27. read32_1 = crc_single_data_calculate(vab1);
  28. /* input reverse */
  29. crc_deinit();
  30. crc_input_data_reverse_config(CRC_INPUT_DATA_BYTE);
  31. read32_2 = crc_single_data_calculate(vab1);
  32. crc_deinit();
  33. crc_input_data_reverse_config(CRC_INPUT_DATA_HALFWORD);
  34. read32_3 = crc_single_data_calculate(vab1);
  35. crc_deinit();
  36. crc_input_data_reverse_config(CRC_INPUT_DATA_WORD);
  37. read32_4 = crc_single_data_calculate(vab1);
  38. /* output reverse */
  39. crc_deinit();
  40. crc_reverse_output_data_enable();
  41. read32_5 = crc_single_data_calculate(vab1);
  42. crc_deinit();
  43. crc_input_data_reverse_config(CRC_INPUT_DATA_BYTE);
  44. crc_reverse_output_data_enable();
  45. read32_6 = crc_single_data_calculate(vab1);
  46. crc_deinit();
  47. crc_input_data_reverse_config(CRC_INPUT_DATA_HALFWORD);
  48. crc_reverse_output_data_enable();
  49. read32_7 = crc_single_data_calculate(vab1);
  50. crc_deinit();
  51. crc_input_data_reverse_config(CRC_INPUT_DATA_WORD);
  52. crc_reverse_output_data_enable();
  53. read32_8 = crc_single_data_calculate(vab1);
  54. /* check the caculation result */
  55. if((read32_1 == 0xf7018a40U)&&(read32_2 == 0x49fc6721U)&&(read32_3 == 0x606444e3U)&&(read32_4 == 0x16d70081U)
  56. &&(read32_5 == 0x025180efU)&&(read32_6 == 0x84e63f92U)&&(read32_7 == 0xc7222606U)&&(read32_8 == 0x8100eb68U)){
  57. success_flag = 0x1U;
  58. gd_eval_led_on(LED1);
  59. }
  60. while (1);
  61. }