~crm/pic_therm

9a2b04f633fa892c9c16d88d551b160f42a7dbfc — Christos Margiolis 2 years ago cc855f9
add hang macro
2 files changed, 13 insertions(+), 8 deletions(-)

M src/main.c
M src/tmr0.c
M src/main.c => src/main.c +11 -6
@@ 31,6 31,11 @@ static char	buf[BUFSIZ+1] = {0}; /* Generic buffer */
	lcd_puts(itoa(&buf[sizeof(buf)-1], v));	\
} while (0)

#define HANG(str) do {				\
	lcd_puts(str);				\
	for (;;);				\
} while (0)

static void
ctx_main(void)
{


@@ 107,14 112,14 @@ void
main(void)
{
	tmr0_init();
	tmr0_set_event(&led_blink, 1000);
	tmr0_set_event(&button_debounce, 1);
	if (tmr0_set_event(&led_blink, 1000) < 0)
		HANG("led_blink event failed");
	if (tmr0_set_event(&button_debounce, 1) < 0)
		HANG("button_debounce event failed");
	lcd_init();
	i2c_init(I2C_MASTER, I2C_SLEW_OFF, I2C_CLK_1MHZ);
	if (bme280_init() < 0) {
		lcd_puts("BME280 error");
		for (;;); /* Hang */
	}
	if (bme280_init() < 0)
		HANG("BME280 error");

	BTN_TRIS = INPUT;
	LED_PORT = 1; /* LED on */

M src/tmr0.c => src/tmr0.c +2 -2
@@ 70,7 70,7 @@ tmr0_set_event(ev_handler handler, uint16_t rate)
		r->handler = handler;
		r->rate = rate;
		r->cnt = 0;
		return (1);
		return (0);
	}
	return (0);
	return (-1);
}