diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/ao.h | 7 | ||||
| -rw-r--r-- | src/drivers/ao_quadrature.c | 7 | ||||
| -rw-r--r-- | src/stm-demo/Makefile | 4 | ||||
| -rw-r--r-- | src/stm-demo/ao_demo.c | 20 | ||||
| -rw-r--r-- | src/stm-demo/ao_pins.h | 14 | ||||
| -rw-r--r-- | src/stm/ao_timer.c | 2 | 
6 files changed, 51 insertions, 3 deletions
| diff --git a/src/core/ao.h b/src/core/ao.h index 1032dd33..5e1fbb9d 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -125,7 +125,12 @@ ao_panic(uint8_t reason);   * ao_timer.c   */ -extern volatile __data uint16_t ao_tick_count; +#ifndef AO_TICK_TYPE +#define AO_TICK_TYPE	uint16_t +#define AO_TICK_SIGNED	int16_t +#endif + +extern volatile __data AO_TICK_TYPE ao_tick_count;  /* Our timer runs at 100Hz */  #define AO_HERTZ		100 diff --git a/src/drivers/ao_quadrature.c b/src/drivers/ao_quadrature.c index aed4999e..6a2c1bba 100644 --- a/src/drivers/ao_quadrature.c +++ b/src/drivers/ao_quadrature.c @@ -18,6 +18,12 @@  #include <ao.h>  #include <ao_quadrature.h>  #include <ao_exti.h> +#if AO_EVENT +#include <ao_event.h> +#define ao_quadrature_queue(q)	ao_event_put_isr(AO_EVENT_QUADRATURE, q, ao_quadrature_count[q]) +#else +#define ao_quadrature_queue(q) +#endif  __xdata int32_t ao_quadrature_count[AO_QUADRATURE_COUNT]; @@ -59,6 +65,7 @@ ao_quadrature_isr(void)  		default:  			continue;  		} +		ao_quadrature_queue(q);  		ao_wakeup(&ao_quadrature_count[q]);  	}  } diff --git a/src/stm-demo/Makefile b/src/stm-demo/Makefile index 52bb7b51..340967fc 100644 --- a/src/stm-demo/Makefile +++ b/src/stm-demo/Makefile @@ -35,7 +35,9 @@ ALTOS_SRC = \  	ao_i2c_stm.c \  	ao_usb_stm.c \  	ao_exti_stm.c \ -	ao_quadrature.c +	ao_event.c \ +	ao_quadrature.c \ +	ao_button.c  PRODUCT=StmDemo-v0.0  PRODUCT_DEF=-DSTM_DEMO diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index 1b9813fe..fe7c69f2 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -17,7 +17,9 @@  #include "ao.h"  #include <ao_exti.h> +#include <ao_event.h>  #include <ao_quadrature.h> +#include <ao_button.h>  struct ao_task demo_task; @@ -150,12 +152,29 @@ ao_temp (void)  	printf ("temp: %d\n", temp);  } +static void +ao_event(void) +{ +	struct ao_event	event; + +	for (;;) { +		flush(); +		ao_event_get(&event); +		printf ("type %1d unit %1d tick %5u value %ld\n", +			event.type, event.unit, event.tick, event.value); +		if (event.value == 100) +			break; +	} + +} +  __code struct ao_cmds ao_demo_cmds[] = {  	{ ao_dma_test,	"D\0DMA test" },  	{ ao_spi_write, "W\0SPI write" },  	{ ao_spi_read, "R\0SPI read" },  	{ ao_i2c_write, "i\0I2C write" },  	{ ao_temp, "t\0Show temp" }, +	{ ao_event, "e\0Monitor event queue" },  	{ 0, NULL }  }; @@ -174,6 +193,7 @@ main(void)  	ao_i2c_init();  	ao_exti_init();  	ao_quadrature_init(); +	ao_button_init();  	ao_timer_set_adc_interval(100); diff --git a/src/stm-demo/ao_pins.h b/src/stm-demo/ao_pins.h index 0c1ed8fc..77e42a28 100644 --- a/src/stm-demo/ao_pins.h +++ b/src/stm-demo/ao_pins.h @@ -170,6 +170,8 @@ struct ao_adc {  #define HAS_I2C_2		0  #define I2C_2_PB10_PB11		0 +#define AO_EVENT		1 +  #define AO_QUADRATURE_COUNT	2  #define AO_QUADRATURE_MODE	AO_EXTI_MODE_PULL_UP @@ -181,4 +183,16 @@ struct ao_adc {  #define AO_QUADRATURE_1_A	3  #define AO_QUADRATURE_1_B	2 +#define AO_BUTTON_COUNT		2 +#define AO_BUTTON_MODE		AO_EXTI_MODE_PULL_UP + +#define AO_BUTTON_0_PORT	&stm_gpioc +#define AO_BUTTON_0		6 + +#define AO_BUTTON_1_PORT	&stm_gpioc +#define AO_BUTTON_1		7 + +#define AO_TICK_TYPE		uint32_t +#define AO_TICK_SIGNED		int32_t +  #endif /* _AO_PINS_H_ */ diff --git a/src/stm/ao_timer.c b/src/stm/ao_timer.c index ebe75366..adec7aad 100644 --- a/src/stm/ao_timer.c +++ b/src/stm/ao_timer.c @@ -17,7 +17,7 @@  #include "ao.h" -volatile __data uint16_t ao_tick_count; +volatile __data AO_TICK_TYPE ao_tick_count;  uint16_t ao_time(void)  { | 
