OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /neorv32/trunk/sw
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

/bootloader/bootloader.c
158,7 → 158,8
void spi_flash_erase_sector(uint32_t addr);
uint8_t spi_flash_read_status(void);
uint8_t spi_flash_read_1st_id(void);
void spi_flash_write_cmd(uint8_t cmd);
void spi_flash_write_enable(void);
void spi_flash_write_addr(uint32_t addr);
 
 
/**********************************************************************//**
312,6 → 313,12
**************************************************************************/
void start_app(void) {
 
// executable available?
if (neorv32_cpu_csr_read(CSR_MSCRATCH) == 0) {
neorv32_uart_print("No executable available.");
return;
}
 
// no need to shutdown or reset the used peripherals
// -> this will be done by application's crt0
 
623,19 → 630,10
**************************************************************************/
uint8_t spi_flash_read_byte(uint32_t addr) {
 
union {
uint32_t uint32;
uint8_t uint8[sizeof(uint32_t)];
} address;
 
address.uint32 = addr;
 
neorv32_spi_cs_en(SPI_FLASH_CS);
 
neorv32_spi_trans(SPI_FLASH_CMD_READ);
neorv32_spi_trans(address.uint8[2]);
neorv32_spi_trans(address.uint8[1]);
neorv32_spi_trans(address.uint8[0]);
spi_flash_write_addr(addr);
uint8_t rdata = (uint8_t)neorv32_spi_trans(0);
 
neorv32_spi_cs_dis(SPI_FLASH_CS);
652,21 → 650,12
**************************************************************************/
void spi_flash_write_byte(uint32_t addr, uint8_t wdata) {
 
union {
uint32_t uint32;
uint8_t uint8[sizeof(uint32_t)];
} address;
spi_flash_write_enable(); // allow write-access
 
address.uint32 = addr;
 
spi_flash_write_cmd(SPI_FLASH_CMD_WRITE_ENABLE); // allow write-access
 
neorv32_spi_cs_en(SPI_FLASH_CS);
 
neorv32_spi_trans(SPI_FLASH_CMD_PAGE_PROGRAM);
neorv32_spi_trans(address.uint8[2]);
neorv32_spi_trans(address.uint8[1]);
neorv32_spi_trans(address.uint8[0]);
spi_flash_write_addr(addr);
neorv32_spi_trans(wdata);
 
neorv32_spi_cs_dis(SPI_FLASH_CS);
709,21 → 698,12
**************************************************************************/
void spi_flash_erase_sector(uint32_t addr) {
 
union {
uint32_t uint32;
uint8_t uint8[sizeof(uint32_t)];
} address;
spi_flash_write_enable(); // allow write-access
 
address.uint32 = addr;
 
spi_flash_write_cmd(SPI_FLASH_CMD_WRITE_ENABLE); // allow write-access
 
neorv32_spi_cs_en(SPI_FLASH_CS);
 
neorv32_spi_trans(SPI_FLASH_CMD_SECTOR_ERASE);
neorv32_spi_trans(address.uint8[2]);
neorv32_spi_trans(address.uint8[1]);
neorv32_spi_trans(address.uint8[0]);
spi_flash_write_addr(addr);
 
neorv32_spi_cs_dis(SPI_FLASH_CS);
 
775,16 → 755,32
 
 
/**********************************************************************//**
* Write command to flash.
*
* @param[in] cmd Command byte.
* Enable flash write access.
**************************************************************************/
void spi_flash_write_cmd(uint8_t cmd) {
void spi_flash_write_enable(void) {
 
neorv32_spi_cs_en(SPI_FLASH_CS);
neorv32_spi_trans(SPI_FLASH_CMD_WRITE_ENABLE);
neorv32_spi_cs_dis(SPI_FLASH_CS);
}
 
neorv32_spi_trans(cmd);
 
neorv32_spi_cs_dis(SPI_FLASH_CS);
/**********************************************************************//**
* Send address word to flash.
*
* @param[in] addr Address word.
**************************************************************************/
void spi_flash_write_addr(uint32_t addr) {
 
union {
uint32_t uint32;
uint8_t uint8[sizeof(uint32_t)];
} address;
 
address.uint32 = addr;
 
neorv32_spi_trans(address.uint8[2]);
neorv32_spi_trans(address.uint8[1]);
neorv32_spi_trans(address.uint8[0]);
}
 
/lib/include/neorv32.h
309,17 → 309,17
* @name IO Device: Machine System Timer (MTIME)
**************************************************************************/
/**@{*/
/** MTIME (time register) low word (r/w) */
#define MTIME_LO (*(IO_REG32 0xFFFFFF90))
/** MTIME (time register) high word (r/w) */
#define MTIME_HI (*(IO_REG32 0xFFFFFF94))
/** MTIME (time register) low word (r/-) */
#define MTIME_LO (*(IO_ROM32 0xFFFFFF90))
/** MTIME (time register) high word (r/-) */
#define MTIME_HI (*(IO_ROM32 0xFFFFFF94))
/** MTIMECMP (time compare register) low word (r/w) */
#define MTIMECMP_LO (*(IO_REG32 0xFFFFFF98))
/** MTIMECMP (time register) high word (r/w) */
#define MTIMECMP_HI (*(IO_REG32 0xFFFFFF9C))
 
/** MTIME (time register) 64-bit access (r/w) */
#define MTIME (*(IO_REG64 (&MTIME_LO)))
/** MTIME (time register) 64-bit access (r/-) */
#define MTIME (*(IO_ROM64 (&MTIME_LO)))
/** MTIMECMP (time compare register) low word (r/w) */
#define MTIMECMP (*(IO_REG64 (&MTIMECMP_LO)))
/**@}*/
/lib/include/neorv32_mtime.h
46,7 → 46,6
 
// prototypes
int neorv32_mtime_available(void);
void neorv32_mtime_set_time(uint64_t time);
uint64_t neorv32_mtime_get_time(void);
void neorv32_mtime_set_timecmp(uint64_t timecmp);
uint64_t neorv32_mtime_get_timecmp(void);
/lib/source/neorv32_mtime.c
62,19 → 62,6
 
 
/**********************************************************************//**
* Set new system time.
*
* @note The MTIME timer increments with the primary processor clock.
*
* @param[in] time New system time (uint64_t)
**************************************************************************/
void neorv32_mtime_set_time(uint64_t time) {
 
MTIME = time;
}
 
 
/**********************************************************************//**
* Get current system time since reset.
*
* @note The MTIME timer increments with the primary processor clock.
83,23 → 70,7
**************************************************************************/
uint64_t neorv32_mtime_get_time(void) {
 
union {
uint64_t uint64;
uint32_t uint32[sizeof(uint64_t)/2];
} sys_mtime;
uint32_t tmp;
 
// make sure there is no overflow in mtime_lo during read
while (1) {
sys_mtime.uint32[1] = MTIME_HI;
sys_mtime.uint32[0] = MTIME_LO;
tmp = MTIME_HI;
if (sys_mtime.uint32[1] == tmp) {
break;
}
}
 
return sys_mtime.uint64;
return MTIME;
}
 
 
115,7 → 86,7
**************************************************************************/
void neorv32_mtime_set_timecmp(uint64_t timecmp) {
 
MTIMECMP_LO = 0xFFFFFFFF; // prevent mtimecmp from temporarily becoming smaller than the lesser of the old and new values
MTIMECMP_LO = -1; // prevent mtimecmp from temporarily becoming smaller than the lesser of the old and new values
MTIMECMP = timecmp;
}
 
/lib/source/neorv32_uart.c
130,7 → 130,7
* Send single char via UART.
*
* @note This function is blocking.
* @warning The 'SIMCOM_UART_OVERRIDE' compiler user flag will forward all UART TX data to the SIMCOM simulation console output.
* @warning The 'DEVNULL_UART_OVERRIDE' compiler user flag will forward all UART TX data to the DEVNULL simulation console output.
*
* @param[in] c Char to be send.
**************************************************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.