fw/icE1usb: Update to support production hardware

Also default build to it since very few people would want to build
firmware targetted to the prototypes ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2020-09-15 22:20:21 +02:00
parent bd83e53ff6
commit 5e86047024
4 changed files with 23 additions and 2 deletions

View File

@ -2,7 +2,7 @@
#ice1usb-proto-icebreaker
#ice1usb-proto-bitsty
#e1-tracer
BOARD ?= ice1usb-proto-icebreaker
BOARD ?= ice1usb
CROSS ?= riscv-none-embed-
CC = $(CROSS)gcc
OBJCOPY = $(CROSS)objcopy

View File

@ -80,19 +80,27 @@ void main()
/* SPI */
spi_init();
serial_no_init();
/* Enable LED now that we're done with SPI */
e1_led_set(true, 0x00);
/* Setup E1 Vref */
int d = 25;
#if defined(BOARD_ICE1USB_PROTO_ICEBREAKER) || defined(BOARD_ICE1USB_PROTO_BITSY)
pdm_set(PDM_E1_CT, true, 128, false);
pdm_set(PDM_E1_P, true, 128 - d, false);
pdm_set(PDM_E1_N, true, 128 + d, false);
#else
pdm_set(PDM_E1_RX0, true, 128 + d, false);
pdm_set(PDM_E1_RX1, true, 128 + d, false);
#endif
/* Setup clock tuning */
pdm_set(PDM_CLK_HI, true, 2048, false);
pdm_set(PDM_CLK_LO, false, 0, false);
/* Enable USB directly */
serial_no_init();
usb_init(&app_stack_desc);
usb_dfu_rt_init();
usb_e1_init();

View File

@ -45,6 +45,12 @@ pdm_set(int chan, bool enable, unsigned value, bool normalize)
}
void
e1_led_set(bool enable, uint8_t cfg)
{
misc_regs->e1_led = (enable ? 0x100 : 0x000) | cfg;
}
uint16_t
e1_tick_read(void)
{

View File

@ -13,6 +13,12 @@
enum pdm_chan {
PDM_CLK_LO = 0,
PDM_CLK_HI = 1,
/* icE1usb */
PDM_E1_RX0 = 2,
PDM_E1_RX1 = 3,
/* icE1usb-proto */
PDM_E1_N = 2,
PDM_E1_P = 3,
PDM_E1_CT = 4,
@ -20,4 +26,5 @@ enum pdm_chan {
void pdm_set(int chan, bool enable, unsigned value, bool normalize);
void e1_led_set(bool enable, uint8_t cfg);
uint16_t e1_tick_read(void);