diff options
Diffstat (limited to 'src/usbtrng-v2.0')
| -rw-r--r-- | src/usbtrng-v2.0/Makefile | 64 | ||||
| -rw-r--r-- | src/usbtrng-v2.0/ao_pins.h | 45 | ||||
| -rw-r--r-- | src/usbtrng-v2.0/ao_usbtrng.c | 45 | 
3 files changed, 154 insertions, 0 deletions
| diff --git a/src/usbtrng-v2.0/Makefile b/src/usbtrng-v2.0/Makefile new file mode 100644 index 00000000..0d237630 --- /dev/null +++ b/src/usbtrng-v2.0/Makefile @@ -0,0 +1,64 @@ +# +# AltOS build +# +# + +include ../stmf0/Makefile.defs + +INC = \ +	ao.h \ +	ao_arch.h \ +	ao_arch_funcs.h \ +	ao_pins.h \ +	ao_product.h \ +	ao_task.h \ +	stm32f0.h + +# +# Common AltOS sources +# +ALTOS_SRC = \ +	ao_interrupt.c \ +	ao_timer.c \ +	ao_panic.c \ +	ao_stdio.c \ +	ao_led.c \ +	ao_romconfig.c \ +	ao_boot_chain.c \ +	ao_cmd.c \ +	ao_usb_stm.c \ +	ao_task.c \ +	ao_product.c + +PRODUCT=usbtrng-v2.0 +PRODUCT_DEF=-DUSBTRNG_V_2_0 +IDPRODUCT=0x0028 + +CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os + +PROGNAME=usbtrng-v2.0 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SRC=$(ALTOS_SRC) ao_usbtrng.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) $(HEX) + +$(PROG): Makefile $(OBJ) altos.ld +	$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + +ao_product.h: ao-make-product.5c ../Version +	$(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +$(OBJ): $(INC) + +distclean:	clean + +clean: +	rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx +	rm -f ao_product.h + +install: + +uninstall: diff --git a/src/usbtrng-v2.0/ao_pins.h b/src/usbtrng-v2.0/ao_pins.h new file mode 100644 index 00000000..bbf5e153 --- /dev/null +++ b/src/usbtrng-v2.0/ao_pins.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2015 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#ifndef _AO_PINS_H_ +#define _AO_PINS_H_ + +#define LED_PORT_ENABLE	STM_RCC_AHBENR_IOPAEN +#define LED_PORT	(&stm_gpioa) +#define LED_PIN_RED	2 +#define LED_PIN_GREEN	3 +#define AO_LED_RED	(1 << LED_PIN_RED) +#define AO_LED_GREEN	(1 << LED_PIN_GREEN) + +#define LEDS_AVAILABLE	(AO_LED_RED | AO_LED_GREEN) + +#define HAS_BEEP	0 + +/* 48MHz clock based on USB */ +#define AO_HSI48	1 + +/* HCLK = 48MHz */ +#define AO_AHB_PRESCALER	1 +#define AO_RCC_CFGR_HPRE_DIV	STM_RCC_CFGR_HPRE_DIV_1 + +/* APB = 48MHz */ +#define AO_APB_PRESCALER	1 +#define AO_RCC_CFGR_PPRE_DIV	STM_RCC_CFGR_PPRE_DIV_1 + +#define HAS_USB		1 + +#endif /* _AO_PINS_H_ */ diff --git a/src/usbtrng-v2.0/ao_usbtrng.c b/src/usbtrng-v2.0/ao_usbtrng.c new file mode 100644 index 00000000..9b6fd4f1 --- /dev/null +++ b/src/usbtrng-v2.0/ao_usbtrng.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include <ao.h> + +static void ao_blink(void) +{ +	for (;;) { +		ao_led_toggle(LEDS_AVAILABLE); +		ao_delay(AO_MS_TO_TICKS(500)); +	} +} + +struct ao_task	blink_task; + +void main(void) +{ +	ao_led_init(LEDS_AVAILABLE); +	ao_led_on(AO_LED_RED); +	ao_clock_init(); +	ao_task_init(); +	ao_timer_init(); + +	ao_cmd_init(); + +	ao_usb_init(); + +	ao_add_task(&blink_task, ao_blink, "blink"); + +	ao_start_scheduler(); +} | 
