1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef EXMC_SDRAM_H 17 #define EXMC_SDRAM_H 18 19 #include "gd32f4xx.h" 20 21 #define SDRAM_DEVICE0_ADDR ((uint32_t)0xC0000000) 22 #define SDRAM_DEVICE1_ADDR ((uint32_t)0xD0000000) 23 24 extern int __bss_start__; 25 extern int __bss_end__; 26 27 /* initialize sdram peripheral */ 28 ErrStatus exmc_synchronous_dynamic_ram_init(uint32_t sdram_device); 29 /* fill the buffer with specified value */ 30 void fill_buffer(uint8_t *pbuffer, uint16_t buffer_lengh, uint16_t offset); 31 /* write a byte buffer(data is 8 bits) to the EXMC SDRAM memory */ 32 void sdram_writebuffer_8(uint32_t sdram_device, uint8_t *pbuffer, uint32_t writeaddr, uint32_t numbytetowrite); 33 /* read a block of 8-bit data from the EXMC SDRAM memory */ 34 void sdram_readbuffer_8(uint32_t sdram_device, uint8_t *pbuffer, uint32_t readaddr, uint32_t numbytetoread); 35 /* write a half-word buffer(data is 16 bits) to the EXMC SDRAM memory */ 36 void sdram_writebuffer_16(uint32_t sdram_device, uint16_t *pbuffer, uint32_t writeaddr, uint32_t numtowrite); 37 /* read a block of 16-bit data from the EXMC SDRAM memory */ 38 void sdram_readbuffer_16(uint32_t sdram_device, uint16_t *pbuffer, uint32_t readaddr, uint32_t numtowrite); 39 40 #endif /* EXMC_SDRAM_H */ 41