Commit 8b2403ad authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

added main module and makefile

parent 6d0101d6
PLATFORM = lm32
OBJS_WRC = wrc_main.o dev/uart.o dev/endpoint.o dev/minic.o dev/pps_gen.o dev/timer.o dev/softpll.o lib/mprintf.o
ifeq ($(PLATFORM), zpu)
CROSS_COMPILE ?= /opt/gcc-zpu/bin/zpu-elf-
CFLAGS_PLATFORM = -abel -Wl,--relax -Wl,--gc-sections
LDFLAGS_PLATFORM = -abel -Wl,--relax -Wl,--gc-sections
OBJS_PLATFORM=
else
CROSS_COMPILE ?= /opt/gcc-lm32/bin/lm32-elf-
CFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled -nostdlib -T target/lm32/ram.ld
OBJS_PLATFORM=target/lm32/crt0.o
endif
CC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump
CFLAGS= $(CFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Os -Iinclude
LDFLAGS= $(LDFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Os -Iinclude
OBJS=$(OBJS_PLATFORM) $(OBJS_WRC)
OUTPUT=wrc
all: $(OBJS)
${CC} -o $(OUTPUT).elf $(OBJS) $(LDFLAGS)
${OBJCOPY} -O binary $(OUTPUT).elf $(OUTPUT).bin
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
./tools/genraminit $(OUTPUT).bin 0 > $(OUTPUT).ram
clean:
rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram
%.o: %.c
${CC} $(CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $^ -o $@
load: all
./tools/zpu-loader $(OUTPUT).bin
tools:
make -C tools
fpga:
- killall -9 vuart_console
../loadfile ../spec_top.bin
./tools/zpu-loader $(OUTPUT).bin
#include <stdio.h>
#include <inttypes.h>
#include "gpio.h"
#include "uart.h"
#include "endpoint.h"
#include "minic.h"
#include "pps_gen.h"
volatile int count = 0;
uint32_t tag_prev;
uint32_t tics_last;
void _irq_entry()
{
volatile uint32_t dummy_tag;
dummy_tag= *(volatile uint32_t*) 0x40004;
// mprintf("tag %d\n", dummy_tag-tag_prev);
count++;
if(timer_get_tics() - tics_last > 1000)
{
tics_last = timer_get_tics();
mprintf("cnt: %d delta %d\n", count, tag_prev-dummy_tag);
count = 0;
}
tag_prev=dummy_tag;
}
int main(void)
{
int rx, tx;
const uint8_t mac_addr[] = {0x00, 0x00, 0xde, 0xad, 0xba, 0xbe};
const uint8_t dst_mac_addr[] = {0x00, 0x00, 0x12, 0x24, 0x46, 0x11};
uint8_t hdr[14];
uart_init();
mprintf("Starting up\n");
gpio_dir(GPIO_PIN_LED, 1);
ep_init(mac_addr);
ep_enable(1, 1);
while(!ep_link_up());
ep_get_deltas(&tx, &rx);
mprintf("delta: tx = %d, rx=%d\n", tx, rx);
minic_init();
pps_gen_init();
//(unsigned int *)(0x40000) = 0x1;
// *(unsigned int *)(0x40024) = 0x1;
for(;;)
{
struct hw_timestamp hwts;
uint32_t utc, nsec;
uint8_t buf[1024];
memcpy(hdr, dst_mac_addr, 6);
hdr[12] = 0x88;
hdr[13] = 0xf7;
minic_tx_frame(hdr, buf, 500, &hwts);
mprintf("TxTs: utc %d nsec %d\n", hwts.utc, hwts.nsec);
delay(1000000);
mprintf("cnt:%d\n", count);
}
}
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