[tuxdroid-svn] r1196 - firmware/fuxusb/trunk/src
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-23 09:53:54
|
Author: Paul_R Date: 2008-05-23 11:53:58 +0200 (Fri, 23 May 2008) New Revision: 1196 Modified: firmware/fuxusb/trunk/src/misc.c firmware/fuxusb/trunk/src/rf.c Log: * Added comments on is_rf_online function. * Improved the LED behavior function. Added a new LED behavior for the bootloader mode. Modified: firmware/fuxusb/trunk/src/misc.c =================================================================== --- firmware/fuxusb/trunk/src/misc.c 2008-05-23 09:30:15 UTC (rev 1195) +++ firmware/fuxusb/trunk/src/misc.c 2008-05-23 09:53:58 UTC (rev 1196) @@ -28,10 +28,31 @@ #include "config.h" #include "global.h" #include "misc.h" +#include "bootloader.h" -/** Start of frame counter */ -static uint16_t usb_sof_counter = 0; +/** \name LED ON/OFF values + * @{ */ +/** \name RF online + * @{ */ +#define ONLINE_LED_ON 0x10 +#define ONLINE_LED_OFF 0x20 +/* @} */ +/** \name RF offline + * @{ */ +#define OFFLINE_LED_ON 0x300 +#define OFFLINE_LED_OFF 0x400 +/* @} */ + +/** \name Bootloader active + * @{ */ +#define BL_LED_ON 0x100 +#define BL_LED_OFF 0x120 +/* @} */ +/* @} */ + +static void blink_led(uint16_t const on_value, uint16_t const off_value); + /** * \brief Control the LED behavior. * The LED blink slowly when the RF is disconnected, and fast when Tux is @@ -40,31 +61,43 @@ * \ingroup misc */ void led_behavior(void) -{ +{ + /* Bootloader mode is activated */ + if (i2c_bootloading_Flag) + { + blink_led(BL_LED_ON, BL_LED_OFF); + } + /* RF is online */ + else if (!RF_OFFLINE) + { + blink_led(ONLINE_LED_ON, ONLINE_LED_OFF); + } + /* RF is offline */ + else + { + blink_led(OFFLINE_LED_ON, OFFLINE_LED_OFF); + } +} + +/** + * \brief Switch on/off the LED depending of the condition. + * \param on_value The SOF value to switch on the LED. + * \param off_value The SOF value to switch off the LED. + */ +static void blink_led(uint16_t const on_value, uint16_t const off_value) +{ + /** Start of frame counter */ + static uint16_t usb_sof_counter = 0; + usb_sof_counter ++; - if(RF_OFFLINE) + if (usb_sof_counter == on_value) { - if (usb_sof_counter == 0x01) - Led_0_off(); - else if (usb_sof_counter == 0x300) - Led_0_on(); - else if (usb_sof_counter == 0x400) - usb_sof_counter = 0x00; + Led_0_on(); } - else + else if (usb_sof_counter >= off_value) { - if (usb_sof_counter == 0x01) - Led_0_off(); - else if (usb_sof_counter == 0x10) - Led_0_on(); - else if (usb_sof_counter == 0x20) - usb_sof_counter = 0x00; - /* - * When the RF is connected, the counter can be greater than 0x20. - * If it's greater than the maximum, clear it - */ - else if (usb_sof_counter > 0x20) - usb_sof_counter = 0; - } + Led_0_off(); + usb_sof_counter = 0x00; + } } Modified: firmware/fuxusb/trunk/src/rf.c =================================================================== --- firmware/fuxusb/trunk/src/rf.c 2008-05-23 09:30:15 UTC (rev 1195) +++ firmware/fuxusb/trunk/src/rf.c 2008-05-23 09:53:58 UTC (rev 1196) @@ -58,6 +58,12 @@ rf_reset_signal = 1; } +/** + * \brief Control if the RF is online. + * \return True if the RF is online. + * If the RF is online, this function return True. + * \ingroup rf + */ bit is_rf_online(void) { /* |