MNRS-BM-BSP/env/TGCP/platform.h

44 lines
1.3 KiB
C
Raw Normal View History

2023-08-20 16:39:20 +02:00
// See LICENSE for license details.
#ifndef _ISS_PLATFORM_H
#define _ISS_PLATFORM_H
// Some things missing from the official encoding.h
#define MCAUSE_INT 0x80000000
#define MCAUSE_CAUSE 0x7FFFFFFF
2024-03-20 12:53:12 +01:00
#define UART0_BASE_ADDR 0xffff0000ULL
#define UART_REG_TXFIFO 0x00
#define UART_REG_RXFIFO 0x04
#define UART_REG_TXCTRL 0x08
#define UART_REG_RXCTRL 0x0c
#define UART_REG_IE 0x10
#define UART_REG_IP 0x14
#define UART_REG_DIV 0x18
#define UART_TXEN 0x1
#define UART0_REG(ADDR) *((volatile uint32_t*) (UART0_BASE_ADDR + ADDR))
2023-08-20 16:39:20 +02:00
/****************************************************************************
* Platform definitions
*****************************************************************************/
#define MEM_BASE_ADDR _AC(0x00000000,UL)
// Helper functions
#define _REG32(p, i) (*(volatile uint32_t *) ((p) + (i)))
#define _REG32P(p, i) ((volatile uint32_t *) ((p) + (i)))
// Misc
#include <stdint.h>
void init_pll(void);
unsigned long get_cpu_freq(void);
unsigned long get_timer_freq(void);
uint64_t get_timer_value(void);
int is_uart_ready(int uart_id);
int try_write_uart_char(int uart_id, char);
void write_uart_char(int uart_id, char);
#endif /* _ISS_PLATFORM_H */