From 9c63c874d0bc96ca2d77fab4d0abf76d193b30a2 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 17 Nov 2017 15:47:59 +0900 Subject: [PATCH] Fix ReGNUal. --- ChangeLog | 2 ++ regnual/regnual.c | 22 ++++++++++++++++++---- regnual/types.h | 2 -- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 145f0f9..271e70f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2017-11-17 NIIBE Yutaka + * regnual/regnual.c (calc_crc32): Enable CRC module. + * src/neug.c (crc32_rv_stop): New. (neug_fini): Call crc32_rv_stop. diff --git a/regnual/regnual.c b/regnual/regnual.c index 1ee5c56..2884c18 100644 --- a/regnual/regnual.c +++ b/regnual/regnual.c @@ -147,19 +147,33 @@ static uint32_t fetch (int i) } struct CRC { - __IO uint32_t DR; - __IO uint8_t IDR; + volatile uint32_t DR; + volatile uint8_t IDR; uint8_t RESERVED0; uint16_t RESERVED1; - __IO uint32_t CR; + volatile uint32_t CR; }; +static struct CRC *const CRC = (struct CRC *)0x40023000; + +struct RCC { + volatile uint32_t CR; + volatile uint32_t CFGR; + volatile uint32_t CIR; + volatile uint32_t APB2RSTR; + volatile uint32_t APB1RSTR; + volatile uint32_t AHBENR; + /* ... */ +}; +static struct RCC *const RCC = (struct RCC *)0x40021000; +#define RCC_AHBENR_CRCEN 0x00000040 + #define CRC_CR_RESET 0x01 static uint32_t calc_crc32 (void) { - struct CRC *CRC = (struct CRC *)0x40023000; int i; + RCC->AHBENR &= ~RCC_AHBENR_CRCEN; CRC->CR = CRC_CR_RESET; for (i = 0; i < 256/4; i++) diff --git a/regnual/types.h b/regnual/types.h index cef27e8..6527e0b 100644 --- a/regnual/types.h +++ b/regnual/types.h @@ -9,5 +9,3 @@ typedef unsigned int uintptr_t; #define FALSE 0 #define NULL 0 - -#define __IO volatile