X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/c104c5fa180ae64a097335f5b7124dca244a13e3..ec12b916610c306899b385f5ccd5450e8a835fc2:/main.c diff --git a/main.c b/main.c index 8b75435..132f1fe 100644 --- a/main.c +++ b/main.c @@ -43,32 +43,12 @@ #include "core/gpio/gpio.h" #include "core/systick/systick.h" +#include "drivers/displays/segment/as1115/as1115.h" + #ifdef CFG_INTERFACE #include "core/cmd/cmd.h" #endif -/**************************************************************************/ -/*! - Approximates a 1 millisecond delay using "nop". This is less - accurate than a dedicated timer, but is useful in certain situations. - - The number of ticks to delay depends on the optimisation level set - when compiling (-O). Depending on the compiler settings, one of the - two defined values for 'delay' should be used. -*/ -/**************************************************************************/ -void delayms(uint32_t ms) -{ - uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 45); // Release Mode (-Os) - // uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations) - - while (delay > 0) - { - __asm volatile ("nop"); - delay--; - } -} - /**************************************************************************/ /*! Main program entry point. After reset, normal code execution will @@ -83,21 +63,32 @@ int main(void) uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; + // lcdTest(); + + + // as1115Test(); + + uint8_t displaybuffer[8]; + + displaybuffer[0] = 0x01 | 0x80; + displaybuffer[1] = 0x02 | 0x40; + displaybuffer[2] = 0x04 | 0x20; + displaybuffer[3] = 0x08 | 0x10; + displaybuffer[4] = 0x10 | 0x08, + displaybuffer[5] = 0x20 | 0x04; + displaybuffer[6] = 0x40 | 0X02; + displaybuffer[7] = 0x80 | 0X01; + + as1115WriteBuffer(displaybuffer); + while (1) { - // Toggle LED once per second ... rollover = 136 years :) + // Toggle LED once per second currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; - if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) - { - gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); - } - else - { - gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); - } + gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, !(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN))); } // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h