Commit 0e8f8909 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

added main headers

parent 1f9ac2c0
#ifndef __BOARD_H
#define __BOARD_H
#define BASE_UART 0x60800
#define BASE_GPIO 0x60400
#define BASE_TIMER 0x61000
#define BASE_PPSGEN 0x50000
#define BASE_EP 0x20000
#define BASE_MINIC 0x10000
#define CPU_CLOCK 62500000ULL
#define UART_BAUDRATE 0 /* not a real UART */
#define GPIO_PIN_LED (0)
static inline int delay(int x)
{
while(x--) asm volatile("nop");
}
#endif
#ifndef __ENDPOINT_H
#define __ENDPOINT_H
void ep_init(uint8_t mac_addr[]);
int ep_enable(int enabled, int autoneg);
int ep_link_up();
#endif
#ifndef __GPIO_H
#define __GPIO_H
#include <inttypes.h>
#include "board.h"
struct GPIO_WB
{
uint32_t CODR; /*Clear output register*/
uint32_t SODR; /*Set output register*/
uint32_t DDR; /*Data direction register (1 means out)*/
uint32_t PSR; /*Pin state register*/
};
static volatile struct GPIO_WB *__gpio = (volatile struct GPIO_WB *) BASE_GPIO;
static inline void gpio_out(int pin, int val)
{
if(val)
__gpio->SODR = (1<<pin);
else
__gpio->CODR = (1<<pin);
}
static inline void gpio_dir(int pin, int val)
{
if(val)
__gpio->DDR |= (1<<pin);
else
__gpio->DDR &= ~(1<<pin);
}
static inline int gpio_in(int pin)
{
return __gpio->PSR & (1<<pin) ? 1: 0;
}
#endif
#ifndef __WRAPPED_INTTYPES_H
#define __WRAPPED_INTTYPES_H
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
#endif
#ifndef __MINIC_H
#define __MINIC_H
#include "types.h"
void minic_init();
int minic_poll_rx();
int minic_rx_frame(uint8_t *hdr, uint8_t *payload, uint32_t buf_size, struct hw_timestamp *hwts);
int minic_tx_frame(uint8_t *hdr, uint8_t *payload, uint32_t size, struct hw_timestamp *hwts);
#endif
#ifndef __PPS_GEN_H
#define __PPS_GEN_H
#include <inttypes.h>
void pps_gen_init();
void pps_gen_adjust_nsec(int32_t how_much);
void shw_pps_gen_adjust_utc(int32_t how_much);
int pps_gen_busy();
void pps_gen_get_time(uint32_t *utc, uint32_t *cntr_nsec);
#endif
#ifndef __TIMER_H
#define __TIMER_H
#include "types.h"
uint32_t timer_get_tics();
void timer_delay(uint32_t how_long);
#endif
#ifndef __TYPES_H
#define __TYPES_H
#include <inttypes.h>
struct hw_timestamp {
int ahead;
uint32_t utc;
uint32_t nsec;
uint32_t phase;
};
#endif
\ No newline at end of file
#ifndef __UART_H
#define __UART_H
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment