From 55e87b4cd630a34e800fe854ecf3262a9e8ac694 Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sat, 21 Mar 2015 01:35:02 +0100 Subject: [PATCH 1/7] Use intrinsics include from toolchain. Specify the complete cpu name to link all. --- makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index fb1d601..a576c5e 100644 --- a/makefile +++ b/makefile @@ -13,10 +13,12 @@ CFLAGS_PRODUCTION += -fomit-frame-pointer -fno-force-addr -finline-limit=1 -fno CFLAGS_PRODUCTION += -Wl,-Map=output.map CFLAGS_DEBUG= -g -Os # -g enables debugging symbol table, -O0 for NO optimization -CC_CMACH = -mmcu=cc430x6137 +CC_CMACH = -mmcu=cc430f6137 CC_DMACH = -D__MSP430_6137__ -DMRFI_CC430 -D__CC430F6137__ #-DCC__MSPGCC didn't need mspgcc defines __GNUC__ CC_DOPT = -DELIMINATE_BLUEROBIN -CC_INCLUDE = -I$(PROJ_DIR)/ -I$(PROJ_DIR)/include/ -I$(PROJ_DIR)/gcc/ -I$(PROJ_DIR)/driver/ -I$(PROJ_DIR)/logic/ -I$(PROJ_DIR)/bluerobin/ -I$(PROJ_DIR)/simpliciti/ -I$(PROJ_DIR)/simpliciti/Components/bsp -I$(PROJ_DIR)/simpliciti/Components/bsp/drivers -I$(PROJ_DIR)/simpliciti/Components/bsp/boards/CC430EM -I$(PROJ_DIR)/simpliciti/Components/mrfi -I$(PROJ_DIR)/simpliciti/Components/nwk -I$(PROJ_DIR)/simpliciti/Components/nwk_applications + +#-I$(PROJ_DIR)/gcc/ +CC_INCLUDE = $(TOOL) -I$(PROJ_DIR)/ -I$(PROJ_DIR)/include/ -I$(PROJ_DIR)/driver/ -I$(PROJ_DIR)/logic/ -I$(PROJ_DIR)/bluerobin/ -I$(PROJ_DIR)/simpliciti/ -I$(PROJ_DIR)/simpliciti/Components/bsp -I$(PROJ_DIR)/simpliciti/Components/bsp/drivers -I$(PROJ_DIR)/simpliciti/Components/bsp/boards/CC430EM -I$(PROJ_DIR)/simpliciti/Components/mrfi -I$(PROJ_DIR)/simpliciti/Components/nwk -I$(PROJ_DIR)/simpliciti/Components/nwk_applications CC_COPT = $(CC_CMACH) $(CC_DMACH) $(CC_DOPT) $(CC_INCLUDE) @@ -35,9 +37,11 @@ SIMPLICICTI_SOURCE = $(SIMPLICICTI_SOURCE_ODD) simpliciti/Components/bsp/bsp.c s SIMPLICICTI_O = $(addsuffix .o,$(basename $(SIMPLICICTI_SOURCE))) -MAIN_SOURCE = ezchronos.c gcc/intrinsics.c +#MAIN_SOURCE = ezchronos.c gcc/intrinsics.c +MAIN_SOURCE = ezchronos.c -MAIN_O = ezchronos.o gcc/intrinsics.o +#MAIN_O = ezchronos.o gcc/intrinsics.o +MAIN_O = ezchronos.o ALL_O = $(LOGIC_O) $(DRIVER_O) $(SIMPLICICTI_O) $(MAIN_O) From 9483feb8d4d9d71cab2abebfe97819449d7cdb9b Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sat, 21 Mar 2015 01:36:12 +0100 Subject: [PATCH 2/7] Add missing include. --- gcc/intrinsics.h | 2 +- include/project.h | 1 + .../bsp/boards/CC430EM/bsp_board_defs.h | 1 + simpliciti/Components/bsp/bsp.h | 1 + .../Components/bsp/mcus/bsp_msp430_defs.h | 20 +++++++++---------- .../mrfi/radios/family5/mrfi_radio.c | 1 + 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gcc/intrinsics.h b/gcc/intrinsics.h index 23f0f5b..6dae042 100644 --- a/gcc/intrinsics.h +++ b/gcc/intrinsics.h @@ -1,7 +1,7 @@ #ifndef __INTRINSICS_H #define __INTRINSICS_H -#include +#include typedef unsigned short istate_t; diff --git a/include/project.h b/include/project.h index cb4f191..ffd9555 100644 --- a/include/project.h +++ b/include/project.h @@ -39,6 +39,7 @@ // ************************************************************************************************* // Include section //pfs +#include #include #include "../bluerobin/bm.h" diff --git a/simpliciti/Components/bsp/boards/CC430EM/bsp_board_defs.h b/simpliciti/Components/bsp/boards/CC430EM/bsp_board_defs.h index 025dbee..bb76952 100644 --- a/simpliciti/Components/bsp/boards/CC430EM/bsp_board_defs.h +++ b/simpliciti/Components/bsp/boards/CC430EM/bsp_board_defs.h @@ -52,6 +52,7 @@ * ------------------------------------------------------------------------------------------------ */ #include "mcus/bsp_msp430_defs.h" +#include /* ------------------------------------------------------------------------------------------------ diff --git a/simpliciti/Components/bsp/bsp.h b/simpliciti/Components/bsp/bsp.h index 9587f0c..a0c9254 100644 --- a/simpliciti/Components/bsp/bsp.h +++ b/simpliciti/Components/bsp/bsp.h @@ -45,6 +45,7 @@ */ #include "bsp_board_defs.h" #include "bsp_macros.h" +#include /* ------------------------------------------------------------------------------------------------ * BSP Defines diff --git a/simpliciti/Components/bsp/mcus/bsp_msp430_defs.h b/simpliciti/Components/bsp/mcus/bsp_msp430_defs.h index 7d15d23..d35ca8c 100644 --- a/simpliciti/Components/bsp/mcus/bsp_msp430_defs.h +++ b/simpliciti/Components/bsp/mcus/bsp_msp430_defs.h @@ -134,16 +134,16 @@ //pfs #if (defined BSP_COMPILER_GCC) #include - //pfs #include - #include - - #define __bsp_ENABLE_INTERRUPTS__() eint() - #define __bsp_DISABLE_INTERRUPTS__() dint() - #define __bsp_INTERRUPTS_ARE_ENABLED__() (READ_SR&0x0008) - - #define __bsp_GET_ISTATE__() (READ_SR&0x0008) - #define __bsp_RESTORE_ISTATE__(x) __asm__("bis %0,r2" : : "ir" ((uint16_t) x)) - #define __bsp_QUOTED_PRAGMA__(x) _Pragma(#x) +#include +#include + +#define __bsp_ENABLE_INTERRUPTS__() eint() +#define __bsp_DISABLE_INTERRUPTS__() dint() +#define __bsp_INTERRUPTS_ARE_ENABLED__() (READ_SR&0x0008) + +#define __bsp_GET_ISTATE__() (READ_SR&0x0008) +#define __bsp_RESTORE_ISTATE__(x) __asm__("bis %0,r2" : : "ir" ((uint16_t) x)) +#define __bsp_QUOTED_PRAGMA__(x) _Pragma(#x) #endif diff --git a/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c b/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c index 3574561..ce29285 100644 --- a/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c +++ b/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c @@ -49,6 +49,7 @@ #include "mrfi_radio_interface.h" #include "smartrf/CC430/smartrf_CC430.h" + /* ------------------------------------------------------------------------------------------------ * Global Constants * ------------------------------------------------------------------------------------------------ From b599c22f4002cc5516724b6d7453b5ac98aaaef7 Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sat, 21 Mar 2015 23:16:34 +0100 Subject: [PATCH 3/7] Add ignore. --- .gitignore | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 258123b..b1671c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ -*.[oa] +tags *.pyc -*.*~ -*.s -.pida-metadata -build -TAGS -doc/*.html -output.map +*.swp +*.o +.gitignore +build/ +*.map From c4e3eea13e4e7c796b23fc1a88f3fb4749055e93 Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sat, 21 Mar 2015 23:16:52 +0100 Subject: [PATCH 4/7] Reformat. --- ezchronos.c | 264 ++++++++++++++++++++++++++-------------------------- 1 file changed, 132 insertions(+), 132 deletions(-) diff --git a/ezchronos.c b/ezchronos.c index 5a2ab71..a02fd67 100644 --- a/ezchronos.c +++ b/ezchronos.c @@ -1,34 +1,34 @@ // ************************************************************************************************* // -// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ -// -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions +// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ +// +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions // are met: -// -// Redistributions of source code must retain the above copyright +// +// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the // distribution. -// +// // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ************************************************************************************************* @@ -66,7 +66,7 @@ #include "acceleration.h" #endif //pfs -#ifndef ELIMINATE_BLUEROBIN +#ifndef ELIMINATE_BLUEROBIN #include "bluerobin.h" #endif #include "rfsimpliciti.h" @@ -122,7 +122,7 @@ void menu_skip_next(line_t line); // Variable holding system internal flags volatile s_system_flags sys; -// Variable holding flags set by logic modules +// Variable holding flags set by logic modules volatile s_request_flags request; // Variable holding message flags @@ -132,7 +132,7 @@ volatile s_message_flags message; // Compensates crystal deviation from 26MHz nominal value u8 rf_frequoffset; -// Function pointers for LINE1 and LINE2 display function +// Function pointers for LINE1 and LINE2 display function void (*fptr_lcd_function_line1)(u8 line, u8 update); void (*fptr_lcd_function_line2)(u8 line, u8 update); @@ -157,7 +157,7 @@ static const addr_t sMyROMAddress = {THIS_DEVICE_ADDRESS}; // ************************************************************************************************* int main(void) { - // Init MCU + // Init MCU init_application(); // Assign initial value to global variables @@ -169,7 +169,7 @@ int main(void) #else display_all_off(); #endif - + // Main control loop: wait in low power mode until some event needs to be processed while(1) { @@ -178,13 +178,13 @@ int main(void) // Process wake-up events if (button.all_flags || sys.all_flags) wakeup_event(); - + // Process actions requested by logic modules if (request.all_flags) process_requests(); - + // Before going to LPM3, update display - if (display.all_flags) display_update(); - } + if (display.all_flags) display_update(); + } } @@ -197,35 +197,35 @@ int main(void) void init_application(void) { volatile unsigned char *ptr; - + // --------------------------------------------------------------------- // Enable watchdog - + // Watchdog triggers after 16 seconds when not cleared -#ifdef USE_WATCHDOG +#ifdef USE_WATCHDOG WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK; #else WDTCTL = WDTPW + WDTHOLD; #endif - + // --------------------------------------------------------------------- // Configure PMM SetVCore(3); - + // Set global high power request enable PMMCTL0_H = 0xA5; PMMCTL0_L |= PMMHPMRE; - PMMCTL0_H = 0x00; + PMMCTL0_H = 0x00; // --------------------------------------------------------------------- - // Enable 32kHz ACLK + // Enable 32kHz ACLK P5SEL |= 0x03; // Select XIN, XOUT on P5.0 and P5.1 UCSCTL6 &= ~XT1OFF; // XT1 On, Highest drive strength UCSCTL6 |= XCAP_3; // Internal load cap UCSCTL3 = SELA__XT1CLK; // Select XT1 as FLL reference - UCSCTL4 = SELA__XT1CLK | SELS__DCOCLKDIV | SELM__DCOCLKDIV; - + UCSCTL4 = SELA__XT1CLK | SELS__DCOCLKDIV | SELM__DCOCLKDIV; + // --------------------------------------------------------------------- // Configure CPU clock for 12MHz _BIS_SR(SCG0); // Disable the FLL control loop @@ -239,19 +239,19 @@ void init_application(void) // UG for optimization. // 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle __delay_cycles(250000); - - // Loop until XT1 & DCO stabilizes, use do-while to insure that + + // Loop until XT1 & DCO stabilizes, use do-while to insure that // body is executed at least once do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG); SFRIFG1 &= ~OFIFG; // Clear fault flags - } while ((SFRIFG1 & OFIFG)); + } while ((SFRIFG1 & OFIFG)); + - // --------------------------------------------------------------------- // Configure port mapping - + // Disable all interrupts __disable_interrupt(); // Get write-access to port mapping registers: @@ -277,15 +277,15 @@ void init_application(void) PMAPPWD = 0; // Re-enable all interrupts __enable_interrupt(); - + // --------------------------------------------------------------------- // Configure ports // --------------------------------------------------------------------- // Reset radio core radio_reset(); - radio_powerdown(); - + radio_powerdown(); + #ifdef FEATURE_PROVIDE_ACCEL // --------------------------------------------------------------------- // Init acceleration sensor @@ -293,11 +293,11 @@ void init_application(void) #else as_disconnect(); #endif - + // --------------------------------------------------------------------- // Init LCD lcd_init(); - + // --------------------------------------------------------------------- // Init buttons init_buttons(); @@ -305,7 +305,7 @@ void init_application(void) // --------------------------------------------------------------------- // Configure Timer0 for use by the clock and delay functions Timer0_Init(); - + // --------------------------------------------------------------------- // Init pressure sensor ps_init(); @@ -339,70 +339,70 @@ void init_global_variables(void) request.all_flags = 0; display.all_flags = 0; message.all_flags = 0; - + // Force full display update when starting up display.flag.full_update = 1; #ifndef ISM_US // Use metric units when displaying values sys.flag.use_metric_units = 1; -#else +#else #ifdef CONFIG_METRIC_ONLY sys.flag.use_metric_units = 1; #endif #endif - + // Read calibration values from info memory read_calibration_values(); #ifdef CONFIG_ALTI_ACCUMULATOR // By default, don't have the altitude accumulator running alt_accum_enable = 0; #endif - - + + #ifdef CONFIG_INFOMEM if(infomem_ready()==-2) { infomem_init(INFOMEM_C, INFOMEM_C+2*INFOMEM_SEGMENT_SIZE); } #endif - + // Set system time to default value reset_clock(); - + // Set date to default value reset_date(); - + #ifdef CONFIG_SIDEREAL reset_sidereal_clock(); #endif - + #ifdef CONFIG_ALARM - // Set alarm time to default value + // Set alarm time to default value reset_alarm(); #endif - + // Set buzzer to default value reset_buzzer(); - + #ifdef CONFIG_STOP_WATCH // Reset stopwatch reset_stopwatch(); #endif - + // Reset altitude measurement #ifdef CONFIG_ALTITUDE reset_altitude_measurement(); #endif - + #ifdef FEATURE_PROVIDE_ACCEL // Reset acceleration measurement reset_acceleration(); #endif - + // Reset BlueRobin stack //pfs - #ifndef ELIMINATE_BLUEROBIN + #ifndef ELIMINATE_BLUEROBIN reset_bluerobin(); #endif @@ -421,8 +421,8 @@ void init_global_variables(void) // Reset SimpliciTI stack reset_rf(); - - // Reset temperature measurement + + // Reset temperature measurement reset_temp_measurement(); #ifdef CONFIG_BATTERY @@ -453,9 +453,9 @@ void wakeup_event(void) message.flag.prepare = 1; message.flag.type_locked = 1; } - + // Clear buttons - button.all_flags = 0; + button.all_flags = 0; } // Process long button press event (while button is held) else if (button.flag.star_long) @@ -473,23 +473,23 @@ void wakeup_event(void) { // Clear button event button.flag.num_long = 0; - + // Call sub menu function ptrMenu_L2->mx_function(LINE2); // Set display update flag - display.flag.full_update = 1; + display.flag.full_update = 1; } // Process single button press event (after button was released) else if (button.all_flags) { // M1 button event --------------------------------------------------------------------- // (Short) Advance to next menu item - if(button.flag.star) + if(button.flag.star) { //skip to next menu item ptrMenu_L1->nx_function(LINE1); - + // Set Line1 display update flag display.flag.line1_full_update = 1; @@ -498,62 +498,62 @@ void wakeup_event(void) } // NUM button event --------------------------------------------------------------------- // (Short) Advance to next menu item - else if(button.flag.num) + else if(button.flag.num) { //skip to next menu item ptrMenu_L2->nx_function(LINE2); - + // Set Line2 display update flag display.flag.line2_full_update = 1; // Clear button flag button.flag.num = 0; - } + } // UP button event --------------------------------------------------------------------- // Activate user function for Line1 menu item - else if(button.flag.up) + else if(button.flag.up) { // Call direct function ptrMenu_L1->sx_function(LINE1); // Set Line1 display update flag display.flag.line1_full_update = 1; - - // Clear button flag + + // Clear button flag button.flag.up = 0; - } + } // DOWN button event --------------------------------------------------------------------- // Activate user function for Line2 menu item - else if(button.flag.down) + else if(button.flag.down) { // Call direct function ptrMenu_L2->sx_function(LINE2); // Set Line1 display update flag display.flag.line2_full_update = 1; - - // Clear button flag + + // Clear button flag button.flag.down = 0; - } + } } - + // Process internal events if (sys.all_flags) { // Idle timeout --------------------------------------------------------------------- if (sys.flag.idle_timeout) { - // Clear timeout flag - sys.flag.idle_timeout = 0; - + // Clear timeout flag + sys.flag.idle_timeout = 0; + // Clear display - clear_display(); + clear_display(); // Set display update flags display.flag.full_update = 1; } } - + // Disable idle timeout sys.flag.idle_timeout_enabled = 0; } @@ -569,7 +569,7 @@ void process_requests(void) { // Do temperature measurement if (request.flag.temperature_measurement) temperature_measurement(FILTER_ON); - + // Do pressure measurement #ifdef CONFIG_ALTITUDE if (request.flag.altitude_measurement) do_altitude_measurement(FILTER_ON); @@ -577,33 +577,33 @@ void process_requests(void) #ifdef CONFIG_ALTI_ACCUMULATOR if (request.flag.altitude_accumulator) altitude_accumulator_periodic(); #endif - + #ifdef FEATURE_PROVIDE_ACCEL // Do acceleration measurement if (request.flag.acceleration_measurement) do_acceleration_measurement(); #endif - + #ifdef CONFIG_BATTERY // Do voltage measurement if (request.flag.voltage_measurement) battery_measurement(); #endif - + #ifdef CONFIG_ALARM // Generate alarm (two signals every second) if (request.flag.alarm_buzzer) start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS); #endif - + #ifdef CONFIG_EGGTIMER // Generate alarm (two signals every second) if (request.flag.eggtimer_buzzer) start_buzzer(2, BUZZER_ON_TICKS, BUZZER_OFF_TICKS); #endif - - + + #ifdef CONFIG_STRENGTH - if (request.flag.strength_buzzer && strength_data.num_beeps != 0) + if (request.flag.strength_buzzer && strength_data.num_beeps != 0) { - start_buzzer(strength_data.num_beeps, - STRENGTH_BUZZER_ON_TICKS, + start_buzzer(strength_data.num_beeps, + STRENGTH_BUZZER_ON_TICKS, STRENGTH_BUZZER_OFF_TICKS); strength_data.num_beeps = 0; } @@ -624,12 +624,12 @@ void display_update(void) { u8 line; u8 string[8]; - + // --------------------------------------------------------------------- // Call Line1 display function if (display.flag.full_update || display.flag.line1_full_update) { - clear_line(LINE1); + clear_line(LINE1); fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_FULL); } else if (ptrMenu_L1->display_update() &&!message.flag.block_line1) @@ -656,20 +656,20 @@ void display_update(void) if (message.flag.show) { line = LINE2; - + // Select message to display if (message.flag.type_locked) memcpy(string, " LOCT", 6); else if (message.flag.type_unlocked) memcpy(string, " OPEN", 6); else if (message.flag.type_lobatt) memcpy(string, "LOBATT", 6); else if (message.flag.type_no_beep_on) memcpy(string, " SILNT", 6); else if (message.flag.type_no_beep_off) memcpy(string, " BEEP", 6); - #ifdef CONFIG_ALARM - else if (message.flag.type_alarm_off_chime_off) + #ifdef CONFIG_ALARM + else if (message.flag.type_alarm_off_chime_off) { memcpy(string, " OFF", 4); line = LINE1; } - else if (message.flag.type_alarm_off_chime_on) + else if (message.flag.type_alarm_off_chime_on) { memcpy(string, "OFFH", 4); line = LINE1; @@ -685,30 +685,30 @@ void display_update(void) line = LINE1; } #endif - - + + // Clear previous content clear_line(line); if(line == LINE2) fptr_lcd_function_line2(line, DISPLAY_LINE_CLEAR); else fptr_lcd_function_line1(line, DISPLAY_LINE_CLEAR); - + if (line == LINE2) display_chars(LCD_SEG_L2_5_0, string, SEG_ON); else display_chars(LCD_SEG_L1_3_0, string, SEG_ON); - + // Next second tick erases message and repaints original screen content (full_update) message.all_flags = 0; if(line == LINE2) message.flag.block_line2 = 1; else message.flag.block_line1 = 1; message.flag.erase = 1; } - + // --------------------------------------------------------------------- // Restore blinking icons (blinking memory is cleared when calling set_value) - if (display.flag.full_update) + if (display.flag.full_update) { //pfs #ifndef ELIMINATE_BLUEROBIN - if (is_bluerobin() == BLUEROBIN_CONNECTED) + if (is_bluerobin() == BLUEROBIN_CONNECTED) { // Turn on beeper icon to show activity display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_OFF); @@ -717,7 +717,7 @@ void display_update(void) } #endif } - + // Clear display flag display.all_flags = 0; } @@ -725,14 +725,14 @@ void display_update(void) // ************************************************************************************************* // @fn to_lpm -// @brief Go to LPM0/3. +// @brief Go to LPM0/3. // @param none // @return none // ************************************************************************************************* void to_lpm(void) { // Go to LPM3 - _BIS_SR(LPM3_bits + GIE); + _BIS_SR(LPM3_bits + GIE); __no_operation(); } @@ -748,8 +748,8 @@ void idle_loop(void) #ifdef CONFIG_CW_TIME // what I'd like to do here is set a morsepos variable // if non-zero it is how many digits we have left to go - // on sending the time. - // we also would have a morse var that would only get set + // on sending the time. + // we also would have a morse var that would only get set // the first send and reset when not in view so we'd only // send the time once @@ -812,10 +812,10 @@ void idle_loop(void) case 4: morsedig=morsemin%10; break; - default: + default: morsepos=5; // done for now } - if (morsedig==0) + if (morsedig==0) morsedig=10; // treat zero as 10 for code algorithm } @@ -825,7 +825,7 @@ void idle_loop(void) int digit=morsedig; // assume we are sending dit for 1-5 or dah for 6-10 (zero is 10) - int ditdah=(morsedig>5)?1:0; + int ditdah=(morsedig>5)?1:0; int dit=CW_DIT_LEN; if (digit>=6) digit-=5; // fold digits 6-10 to 1-5 @@ -868,21 +868,21 @@ void read_calibration_values(void) u8 cal_data[CALIBRATION_DATA_LENGTH]; // Temporary storage for constants u8 i; u8 * flash_mem; // Memory pointer - + // Read calibration data from Info D memory flash_mem = (u8 *)0x1800; for (i=0; i 20) && (rf_frequoffset < (256-20))) { rf_frequoffset = 0; - } + } sTemp.offset = (s16)((cal_data[2] << 8) + cal_data[3]); #ifdef CONFIG_BATTERY sBatt.offset = (s16)((cal_data[4] << 8) + cal_data[5]); @@ -917,7 +917,7 @@ void read_calibration_values(void) } else { - sAlt.altitude_offset = 0; + sAlt.altitude_offset = 0; } #endif } @@ -935,15 +935,15 @@ void menu_skip_next(line_t line) { // Clean up display before activating next menu item fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR); - + if(++menu_L1_position>=menu_L1_size) { menu_L1_position=0; } - + // Go to next menu entry ptrMenu_L1 = menu_L1[menu_L1_position]; - + // Assign new display function fptr_lcd_function_line1 = ptrMenu_L1->display_function; } @@ -954,7 +954,7 @@ void menu_skip_next(line_t line) if(++menu_L2_position>=menu_L2_size) menu_L2_position=0; - + // Go to next menu entry ptrMenu_L2 = menu_L2[menu_L2_position]; From 88c67d4235959fe349a7240624b18667a3b002ea Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sun, 22 Mar 2015 03:38:07 +0100 Subject: [PATCH 5/7] Place all file object in a dir. Clean makefile. --- makefile | 139 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 46 deletions(-) diff --git a/makefile b/makefile index a576c5e..4056740 100644 --- a/makefile +++ b/makefile @@ -4,10 +4,13 @@ CPU = MSP430 CC = msp430-gcc LD = msp430-ld PYTHON := $(shell which python2 || which python) +VERBOSE = PROJ_DIR =. BUILD_DIR = build +OBJ_DIR = obj CFLAGS_PRODUCTION = -Os -Wall#-Wl,--gc-sections # -ffunction-sections # -fdata-sections -fno-inline-functions# -O optimizes + # more optimizion flags CFLAGS_PRODUCTION += -fomit-frame-pointer -fno-force-addr -finline-limit=1 -fno-schedule-insns CFLAGS_PRODUCTION += -Wl,-Map=output.map @@ -17,40 +20,91 @@ CC_CMACH = -mmcu=cc430f6137 CC_DMACH = -D__MSP430_6137__ -DMRFI_CC430 -D__CC430F6137__ #-DCC__MSPGCC didn't need mspgcc defines __GNUC__ CC_DOPT = -DELIMINATE_BLUEROBIN -#-I$(PROJ_DIR)/gcc/ -CC_INCLUDE = $(TOOL) -I$(PROJ_DIR)/ -I$(PROJ_DIR)/include/ -I$(PROJ_DIR)/driver/ -I$(PROJ_DIR)/logic/ -I$(PROJ_DIR)/bluerobin/ -I$(PROJ_DIR)/simpliciti/ -I$(PROJ_DIR)/simpliciti/Components/bsp -I$(PROJ_DIR)/simpliciti/Components/bsp/drivers -I$(PROJ_DIR)/simpliciti/Components/bsp/boards/CC430EM -I$(PROJ_DIR)/simpliciti/Components/mrfi -I$(PROJ_DIR)/simpliciti/Components/nwk -I$(PROJ_DIR)/simpliciti/Components/nwk_applications - -CC_COPT = $(CC_CMACH) $(CC_DMACH) $(CC_DOPT) $(CC_INCLUDE) - -LOGIC_SOURCE = logic/acceleration.c logic/alarm.c logic/altitude.c logic/battery.c logic/clock.c logic/date.c logic/menu.c logic/rfbsl.c logic/rfsimpliciti.c logic/stopwatch.c logic/temperature.c logic/test.c logic/user.c logic/phase_clock.c logic/eggtimer.c logic/prout.c logic/vario.c logic/sidereal.c logic/strength.c \ - logic/sequence.c logic/gps.c logic/dst.c - -LOGIC_O = $(addsuffix .o,$(basename $(LOGIC_SOURCE))) +CC_INCLUDE = -I$(PROJ_DIR)/ \ + -I$(PROJ_DIR)/include/ \ + -I$(PROJ_DIR)/driver/ \ + -I$(PROJ_DIR)/logic/ \ + -I$(PROJ_DIR)/bluerobin/ \ + -I$(PROJ_DIR)/simpliciti/ \ + -I$(PROJ_DIR)/simpliciti/Components/bsp \ + -I$(PROJ_DIR)/simpliciti/Components/bsp/drivers \ + -I$(PROJ_DIR)/simpliciti/Components/bsp/boards/CC430EM \ + -I$(PROJ_DIR)/simpliciti/Components/mrfi \ + -I$(PROJ_DIR)/simpliciti/Components/nwk \ + -I$(PROJ_DIR)/simpliciti/Components/nwk_applications + +CC_COPT = $(VERBOSE) $(CC_CMACH) $(CC_DMACH) $(CC_DOPT) $(CC_INCLUDE) + +LOGIC_SOURCE = logic/acceleration.c \ + logic/alarm.c \ + logic/altitude.c \ + logic/battery.c \ + logic/clock.c \ + logic/date.c \ + logic/menu.c \ + logic/rfbsl.c \ + logic/rfsimpliciti.c \ + logic/stopwatch.c \ + logic/temperature.c \ + logic/test.c \ + logic/user.c \ + logic/phase_clock.c \ + logic/eggtimer.c \ + logic/prout.c \ + logic/vario.c \ + logic/sidereal.c \ + logic/strength.c \ + logic/sequence.c \ + logic/gps.c \ + logic/dst.c \ + # + +DRIVER_SOURCE = driver/adc12.c \ + driver/buzzer.c \ + driver/display.c \ + driver/display1.c \ + driver/pmm.c \ + driver/ports.c \ + driver/radio.c \ + driver/rf1a.c \ + driver/timer.c \ + driver/vti_as.c \ + driver/vti_ps.c \ + driver/dsp.c \ + driver/infomem.c \ + # -DRIVER_SOURCE = driver/adc12.c driver/buzzer.c driver/display.c driver/display1.c driver/pmm.c driver/ports.c driver/radio.c driver/rf1a.c driver/timer.c driver/vti_as.c driver/vti_ps.c driver/dsp.c driver/infomem.c - -DRIVER_O = $(addsuffix .o,$(basename $(DRIVER_SOURCE))) SIMPLICICTI_SOURCE_ODD = simpliciti/Applications/application/End_Device/main_ED_BM.c # changed directory from End Device to End_Device -SIMPLICICTI_SOURCE = $(SIMPLICICTI_SOURCE_ODD) simpliciti/Components/bsp/bsp.c simpliciti/Components/mrfi/mrfi.c simpliciti/Components/nwk/nwk.c simpliciti/Components/nwk/nwk_api.c simpliciti/Components/nwk/nwk_frame.c simpliciti/Components/nwk/nwk_globals.c simpliciti/Components/nwk/nwk_QMgmt.c simpliciti/Components/nwk_applications/nwk_freq.c simpliciti/Components/nwk_applications/nwk_ioctl.c simpliciti/Components/nwk_applications/nwk_join.c simpliciti/Components/nwk_applications/nwk_link.c simpliciti/Components/nwk_applications/nwk_mgmt.c simpliciti/Components/nwk_applications/nwk_ping.c simpliciti/Components/nwk_applications/nwk_security.c - -SIMPLICICTI_O = $(addsuffix .o,$(basename $(SIMPLICICTI_SOURCE))) +SIMPLICICTI_SOURCE = $(SIMPLICICTI_SOURCE_ODD) \ + simpliciti/Components/bsp/bsp.c \ + simpliciti/Components/mrfi/mrfi.c \ + simpliciti/Components/nwk/nwk.c \ + simpliciti/Components/nwk/nwk_api.c \ + simpliciti/Components/nwk/nwk_frame.c \ + simpliciti/Components/nwk/nwk_globals.c \ + simpliciti/Components/nwk/nwk_QMgmt.c \ + simpliciti/Components/nwk_applications/nwk_freq.c \ + simpliciti/Components/nwk_applications/nwk_ioctl.c \ + simpliciti/Components/nwk_applications/nwk_join.c \ + simpliciti/Components/nwk_applications/nwk_link.c \ + simpliciti/Components/nwk_applications/nwk_mgmt.c \ + simpliciti/Components/nwk_applications/nwk_ping.c \ + simpliciti/Components/nwk_applications/nwk_security.c \ + # -#MAIN_SOURCE = ezchronos.c gcc/intrinsics.c MAIN_SOURCE = ezchronos.c -#MAIN_O = ezchronos.o gcc/intrinsics.o -MAIN_O = ezchronos.o - -ALL_O = $(LOGIC_O) $(DRIVER_O) $(SIMPLICICTI_O) $(MAIN_O) - -ALL_S = $(addsuffix .s,$(basename $(LOGIC_SOURCE))) $(addsuffix .s,$(basename $(DRIVER_SOURCE))) $(addsuffix .s,$(basename $(SIMPLICICTI_SOURCE))) \ - $(addsuffix .s,$(basename $(MAIN_SOURCE))) - -EXTRA_O = even_in_range.o - ALL_C = $(LOGIC_SOURCE) $(DRIVER_SOURCE) $(SIMPLICICTI_SOURCE) $(MAIN_SOURCE) +ALL_S = $(addsuffix .s,$(basename $(LOGIC_SOURCE))) \ + $(addsuffix .s,$(basename $(DRIVER_SOURCE))) \ + $(addsuffix .s,$(basename $(SIMPLICICTI_SOURCE))) \ + $(addsuffix .s,$(basename $(MAIN_SOURCE))) \ + # + +EXTRA_O = $(OBJ_DIR)/even_in_range.o +ALL_O = $(patsubst %.c,$(OBJ_DIR)/%.o,$(addsuffix .c, $(basename $(ALL_C)))) USE_CFLAGS = $(CFLAGS_PRODUCTION) @@ -65,30 +119,20 @@ main: build config.h even_in_range $(ALL_O) $(EXTRA_O) build @echo "Compiling $@ for $(CPU)..." $(CC) $(CC_CMACH) $(CFLAGS_PRODUCTION) -o $(BUILD_DIR)/eZChronos.elf $(ALL_O) $(EXTRA_O) @echo "Convert to TI Hex file" - $(PYTHON) tools/memory.py -i build/eZChronos.elf -o build/eZChronos.txt - -#debug: foo -# @echo USE_CFLAGS = $(CFLAGS_DEBUG) -# call call_debug + $(PYTHON) tools/memory.py -i $(BUILD_DIR)/eZChronos.elf -o $(BUILD_DIR)/eZChronos.txt -#$(ALL_O): config.h project/project.h $(addsuffix .o,$(basename $@)) -# $(CC) $(CC_COPT) $(USE_CFLAGS) -c $(basename $@).c -o $@ - -$(ALL_O): %.o: %.c config.h include/project.h +$(ALL_O): $(OBJ_DIR)/%.o: %.c config.h include/project.h + @mkdir -p $(dir $@) $(CC) $(CC_COPT) $(USE_CFLAGS) $(CONFIG_FLAGS) -c $< -o $@ -# $(CC) -c $(CFLAGS) $< -o $@ - $(ALL_S): %.s: %.o config.h include/project.h msp430-objdump -D $< > $@ -# $(CC) -c $(CFLAGS) $< -o $@ - debug: build even_in_range $(ALL_O) @echo "Compiling $@ for $(CPU) in debug" $(CC) $(CC_CMACH) $(CFLAGS_DEBUG) -o $(BUILD_DIR)/eZChronos.dbg.elf $(ALL_O) $(EXTRA_O) @echo "Convert to TI Hex file" - $(PYTHON) tools/memory.py -i build/eZChronos.dbg.elf -o build/eZChronos.txt + $(PYTHON) tools/memory.py -i $(BUILD_DIR)/eZChronos.dbg.elf -o $(BUILD_DIR)/eZChronos.txt debug_asm: $(ALL_S) @echo "Compiling $@ for $(CPU) in debug" @@ -96,22 +140,26 @@ debug_asm: $(ALL_S) source_index: $(ALL_S) for i in $(ALL_S); do echo analyze $$i && m4s init < $$i; done -etags: $(ALL_C) +tags: $(ALL_C) etags $^ even_in_range: @echo "Assembling $@ in one step for $(CPU)..." - $(CC) -D_GNU_ASSEMBLER_ -x assembler-with-cpp -c even_in_range.s -o even_in_range.o + @mkdir -p $(OBJ_DIR) + $(CC) -D_GNU_ASSEMBLER_ -x assembler-with-cpp -c even_in_range.s -o $(OBJ_DIR)/even_in_range.o clean: @echo "Removing files..." - rm -f $(ALL_O) - rm -rf build/* + rm -rf $(BUILD_DIR)/* + rm -rf $(OBJ_DIR)/* build: - mkdir -p build + @echo "Make dirs.." + mkdir -p $(BUILD_DIR) + mkdir -p $(OBJ_DIR) config.h: + @echo "Generate confing.." $(PYTHON) tools/config.py git update-index --assume-unchanged config.h 2> /dev/null || true @@ -125,7 +173,6 @@ help: @echo " debug" @echo " clean" @echo " debug_asm" -#rm *.o $(BUILD_DIR)* # From 1a80a3102f43cd17567835367c71e2ba3109347b Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sun, 22 Mar 2015 03:38:18 +0100 Subject: [PATCH 6/7] Reformat. --- driver/display.c | 142 ++++----- driver/timer.c | 280 +++++++++--------- driver/vti_as.c | 122 ++++---- driver/vti_ps.c | 166 +++++------ ezchronos.c | 18 +- gcc/intrinsics.c | 20 +- .../mrfi/radios/family5/mrfi_radio.c | 10 +- 7 files changed, 379 insertions(+), 379 deletions(-) diff --git a/driver/display.c b/driver/display.c index 2c8c97b..82c49f6 100644 --- a/driver/display.c +++ b/driver/display.c @@ -1,34 +1,34 @@ // ************************************************************************************************* // -// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ -// -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions +// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ +// +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions // are met: -// -// Redistributions of source code must retain the above copyright +// +// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the // distribution. -// +// // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ************************************************************************************************* @@ -97,18 +97,18 @@ void lcd_init(void) // LCD_FREQ = ACLK/12/8 = 341.3Hz flickers in the sun // LCD_FREQ = ACLK/10/8 = 409.6Hz still flickers in the sun when watch is moving (might be negligible) - + // LCD_FREQ = ACLK/8/8 = 512Hz no flickering, even when watch is moving // Frame frequency = 512Hz/2/4 = 64Hz, LCD mux 4, LCD on LCDBCTL0 = (LCDDIV0 + LCDDIV1 + LCDDIV2) | (LCDPRE0 + LCDPRE1) | LCD4MUX | LCDON; // LCB_BLK_FREQ = ACLK/8/4096 = 1Hz - LCDBBLKCTL = LCDBLKPRE0 | LCDBLKPRE1 | LCDBLKDIV0 | LCDBLKDIV1 | LCDBLKDIV2 | LCDBLKMOD0; + LCDBBLKCTL = LCDBLKPRE0 | LCDBLKPRE1 | LCDBLKDIV0 | LCDBLKDIV1 | LCDBLKDIV2 | LCDBLKMOD0; // I/O to COM outputs P5SEL |= (BIT5 | BIT6 | BIT7); P5DIR |= (BIT5 | BIT6 | BIT7); - + // Activate LCD output LCDBPCTL0 = 0xFFFF; // Select LCD segments S0-S15 LCDBPCTL1 = 0x00FF; // Select LCD segments S16-S22 @@ -131,11 +131,11 @@ void clear_display_all(void) // Clear generic content clear_line(LINE1); clear_line(LINE2); - + // Clean up function-specific content fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR); - fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); - + fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); + } @@ -183,7 +183,7 @@ void clear_line(u8 line) // bits Segments to address // bitmask Bitmask for particular display item // mode On, off or blink segments -// @return +// @return // ************************************************************************************************* void write_lcd_mem(u8 * lcdmem, u8 bits, u8 bitmask, u8 state) { @@ -191,7 +191,7 @@ void write_lcd_mem(u8 * lcdmem, u8 bits, u8 bitmask, u8 state) { // Clear segments before writing *lcdmem = (u8)(*lcdmem & ~bitmask); - + // Set visible segments *lcdmem = (u8)(*lcdmem | bits); } @@ -205,7 +205,7 @@ void write_lcd_mem(u8 * lcdmem, u8 bits, u8 bitmask, u8 state) // Clear visible / blink segments before writing *lcdmem = (u8)(*lcdmem & ~bitmask); *(lcdmem+0x20) = (u8)(*(lcdmem+0x20) & ~bitmask); - + // Set visible / blink segments *lcdmem = (u8)(*lcdmem | bits); *(lcdmem+0x20) = (u8)(*(lcdmem+0x20) | bits); @@ -214,7 +214,7 @@ void write_lcd_mem(u8 * lcdmem, u8 bits, u8 bitmask, u8 state) { // Clear visible segments before writing *lcdmem = (u8)(*lcdmem & ~bitmask); - + // Set visible segments *lcdmem = (u8)(*lcdmem | bits); @@ -239,20 +239,20 @@ void write_lcd_mem(u8 * lcdmem, u8 bits, u8 bitmask, u8 state) // Option to convert leading '0' into whitespace (blanks) // @param u32 n integer to convert // u8 digits number of digits -// u8 blanks fill up result string with number of whitespaces instead of leading zeros +// u8 blanks fill up result string with number of whitespaces instead of leading zeros // @return u8 string // ************************************************************************************************* u8 * itoa(u32 n, u8 digits, u8 blanks) { u8 i; u8 digits1 = digits; - + // Preset result string memcpy(itoa_str, "0000000", 7); // Return empty string if number of digits is invalid (valid range for digits: 1-7) if ((digits == 0) || (digits > 7)) return (itoa_str); - + // Numbers 0 .. 180 can be copied from itoa_conversion_table without conversion if (n <= 180) { @@ -260,7 +260,7 @@ u8 * itoa(u32 n, u8 digits, u8 blanks) { memcpy(itoa_str+(digits-3), itoa_conversion_table[n], 3); } - else // digits == 1 || 2 + else // digits == 1 || 2 { memcpy(itoa_str, itoa_conversion_table[n]+(3-digits), digits); } @@ -268,16 +268,16 @@ u8 * itoa(u32 n, u8 digits, u8 blanks) else // For n > 180 need to calculate string content { // Calculate digits from least to most significant number - do - { - itoa_str[digits-1] = n % 10 + '0'; + do + { + itoa_str[digits-1] = n % 10 + '0'; n /= 10; - } while (--digits > 0); + } while (--digits > 0); } // Remove specified number of leading '0', always keep last one - i = 0; - while ((itoa_str[i] == '0') && (i < digits1-1)) + i = 0; + while ((itoa_str[i] == '0') && (i < digits1-1)) { if (blanks > 0) { @@ -287,9 +287,9 @@ u8 * itoa(u32 n, u8 digits, u8 blanks) } i++; } - - return (itoa_str); -} + + return (itoa_str); +} // ************************************************************************************************* @@ -347,7 +347,7 @@ void display_hours_12_or_24(u8 segments, u32 value, u8 digits, u8 blanks, u8 dis { #endif #if (OPTION_TIME_DISPLAY != CLOCK_AM_PM) - // Display hours in 24H time format + // Display hours in 24H time format display_value1(segments, (u16) value, digits, blanks, disp_mode); #endif #if (OPTION_TIME_DISPLAY == CLOCK_DISPLAY_SELECT) @@ -391,19 +391,19 @@ void display_symbol(u8 symbol, u8 mode) u8 * lcdmem; u8 bits; u8 bitmask; - - if (symbol <= LCD_SEG_L2_DP) + + if (symbol <= LCD_SEG_L2_DP) { // Get LCD memory address for symbol from table lcdmem = (u8 *)segments_lcdmem[symbol]; - + // Get bits for symbol from table bits = segments_bitmask[symbol]; - + // Bitmask for symbols equals bits bitmask = bits; - - // Write LCD memory + + // Write LCD memory write_lcd_mem(lcdmem, bits, bitmask, mode); } } @@ -412,7 +412,7 @@ void display_symbol(u8 symbol, u8 mode) // ************************************************************************************************* // @fn display_char // @brief Write to 7-segment characters. -// @param u8 segment A valid LCD segment +// @param u8 segment A valid LCD segment // u8 chr Character to display // u8 mode SEG_ON, SEG_OFF, SEG_BLINK // @return none @@ -422,7 +422,7 @@ void display_char(u8 segment, u8 chr, u8 mode) u8 * lcdmem; // Pointer to LCD memory u8 bitmask; // Bitmask for character u8 bits, bits1; // Bits to write - + // Write to single 7-segment character if ((segment >= LCD_SEG_L1_3) && (segment <= LCD_SEG_L2_DP)) { @@ -431,9 +431,9 @@ void display_char(u8 segment, u8 chr, u8 mode) // Get bitmask for character from table bitmask = segments_bitmask[segment]; - + // Get bits from font set - if ((chr >= 0x30) && (chr <= 0x5A)) + if ((chr >= 0x30) && (chr <= 0x5A)) { // Use font set bits = lcd_font[chr-0x30]; @@ -451,29 +451,29 @@ void display_char(u8 segment, u8 chr, u8 mode) // When addressing LINE2 7-segment characters need to swap high- and low-nibble, // because LCD COM/SEG assignment is mirrored against LINE1 - if (segment >= LCD_SEG_L2_5) + if (segment >= LCD_SEG_L2_5) { bits1 = ((bits << 4) & 0xF0) | ((bits >> 4) & 0x0F); bits = bits1; // When addressing LCD_SEG_L2_5, need to convert ASCII '1' and 'L' to 1 bit, // because LCD COM/SEG assignment is special for this incomplete character - if (segment == LCD_SEG_L2_5) + if (segment == LCD_SEG_L2_5) { if ((chr == '1') || (chr == 'L')) bits = BIT7; } } - - // Physically write to LCD memory + + // Physically write to LCD memory write_lcd_mem(lcdmem, bits, bitmask, mode); } -} - +} + // ************************************************************************************************* // @fn display_chars // @brief Write to consecutive 7-segment characters. -// @param u8 segments LCD segment array +// @param u8 segments LCD segment array // u8 * str Pointer to a string // u8 mode SEG_ON, SEG_OFF, SEG_BLINK // @return none @@ -483,7 +483,7 @@ void display_chars(u8 segments, u8 * str, u8 mode) u8 i; u8 length = 0; // Write length u8 char_start; // Starting point for consecutive write - + //single charakter if ((segments >= LCD_SEG_L1_3) && (segments <= LCD_SEG_L2_DP)) { @@ -512,7 +512,7 @@ void display_chars(u8 segments, u8 * str, u8 mode) case LCD_SEG_L2_4_2: length=3; char_start=LCD_SEG_L2_4; break; case LCD_SEG_L2_4_3: length=2; char_start=LCD_SEG_L2_4; break; } - + // Write to consecutive digits for(i=0; i interrupt (TIMER0_A0_VECTOR) TIMER0_A0_ISR(void) #else @@ -326,32 +326,32 @@ __interrupt void TIMER0_A0_ISR(void) { static u8 button_lock_counter = 0; static u8 button_beep_counter = 0; - - // Disable IE + + // Disable IE TA0CCTL0 &= ~CCIE; - // Reset IRQ flag - TA0CCTL0 &= ~CCIFG; + // Reset IRQ flag + TA0CCTL0 &= ~CCIFG; // Add 1 sec to TACCR0 register (IRQ will be asserted at 0x7FFF and 0xFFFF = 1 sec intervals) TA0CCR0 += 32768; - // Enable IE + // Enable IE TA0CCTL0 |= CCIE; - + // Add 1 second to global time clock_tick(); - + // Set clock update flag display.flag.update_time = 1; - + // While SimpliciTI stack operates or BlueRobin searches, freeze system state //pfs #ifdef ELIMINATE_BLUEROBIN if (is_rf()) #else - if (is_rf() || is_bluerobin_searching()) + if (is_rf() || is_bluerobin_searching()) #endif { // SimpliciTI automatic timeout - if (sRFsmpl.timeout == 0) + if (sRFsmpl.timeout == 0) { simpliciti_flag |= SIMPLICITI_TRIGGER_STOP; } @@ -359,21 +359,21 @@ __interrupt void TIMER0_A0_ISR(void) { sRFsmpl.timeout--; } - + // Exit from LPM3 on RETI - _BIC_SR_IRQ(LPM3_bits); + _BIC_SR_IRQ(LPM3_bits); return; } - + // ------------------------------------------------------------------- // Service modules that require 1/min processing - if (sTime.drawFlag >= 2) + if (sTime.drawFlag >= 2) { #ifdef CONFIG_BATTERY // Measure battery voltage to keep track of remaining battery life request.flag.voltage_measurement = 1; #endif - + #ifdef CONFIG_ALARM // If the chime is enabled, we beep here if (sTime.minute == 0) { @@ -430,7 +430,7 @@ __interrupt void TIMER0_A0_ISR(void) #endif #ifdef CONFIG_ALARM // Generate alarm signal - if (sAlarm.state == ALARM_ON) + if (sAlarm.state == ALARM_ON) { // Decrement alarm duration counter if (sAlarm.duration-- > 0) @@ -444,31 +444,31 @@ __interrupt void TIMER0_A0_ISR(void) } } #endif - + #ifdef CONFIG_PROUT if (is_prout()) prout_tick(); #endif - + #ifdef CONFIG_STRENGTH // One more second gone by. if(is_strength()) { strength_tick(); - } + } #endif // Do a temperature measurement each second while menu item is active if (is_temp_measurement()) request.flag.temperature_measurement = 1; - + // Do a pressure measurement each second while menu item is active #ifdef CONFIG_ALTITUDE - if (is_altitude_measurement()) + if (is_altitude_measurement()) { // Countdown altitude measurement timeout while menu item is active sAlt.timeout--; // Stop measurement when timeout has elapsed - if (sAlt.timeout == 0) + if (sAlt.timeout == 0) { stop_altitude_measurement(); // Show ---- m/ft @@ -477,25 +477,25 @@ __interrupt void TIMER0_A0_ISR(void) display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } - + // In case we missed the IRQ due to debouncing, get data now if ((PS_INT_IN & PS_INT_PIN) == PS_INT_PIN) request.flag.altitude_measurement = 1; - } + } #endif #ifdef FEATURE_PROVIDE_ACCEL // Count down timeout - if (is_acceleration_measurement()) + if (is_acceleration_measurement()) { - // Countdown acceleration measurement timeout + // Countdown acceleration measurement timeout sAccel.timeout--; // Stop measurement when timeout has elapsed - if (sAccel.timeout == 0) as_stop(); - + if (sAccel.timeout == 0) as_stop(); + // If DRDY is (still) high, request data again - if ((AS_INT_IN & AS_INT_PIN) == AS_INT_PIN) request.flag.acceleration_measurement = 1; - } + if ((AS_INT_IN & AS_INT_PIN) == AS_INT_PIN) request.flag.acceleration_measurement = 1; + } #endif //pfs @@ -503,12 +503,12 @@ __interrupt void TIMER0_A0_ISR(void) // If BlueRobin transmitter is connected, get data from API if (is_bluerobin()) get_bluerobin_data(); #endif - + #ifdef CONFIG_BATTERY // If battery is low, decrement display counter if (sys.flag.low_battery) { - if (sBatt.lobatt_display-- == 0) + if (sBatt.lobatt_display-- == 0) { message.flag.prepare = 1; message.flag.type_lobatt = 1; @@ -516,7 +516,7 @@ __interrupt void TIMER0_A0_ISR(void) } } #endif - + // If a message has to be displayed, set display flag if (message.all_flags) { @@ -531,16 +531,16 @@ __interrupt void TIMER0_A0_ISR(void) message.flag.block_line1 = 0; message.flag.block_line2 = 0; display.flag.full_update = 1; - } + } } - + // ------------------------------------------------------------------- // Check idle timeout, set timeout flag if (sys.flag.idle_timeout_enabled) { if (sTime.system_time - sTime.last_activity > INACTIVITY_TIME) sys.flag.idle_timeout = 1; //setFlag(sysFlag_g, SYS_TIMEOUT_IDLE); } - + // ------------------------------------------------------------------- // Turn the Backlight off after timeout if (sButton.backlight_status == 1) @@ -567,12 +567,12 @@ __interrupt void TIMER0_A0_ISR(void) { // Toggle no_beep buttons flag sys.flag.no_beep = ~sys.flag.no_beep; - + // Show "beep / nobeep" message synchronously with next second tick message.flag.prepare = 1; if (sys.flag.no_beep) message.flag.type_no_beep_on = 1; else message.flag.type_no_beep_off = 1; - + // Reset button beep counter button_beep_counter = 0; } @@ -582,12 +582,12 @@ __interrupt void TIMER0_A0_ISR(void) { // Toggle lock / unlock buttons flag sys.flag.lock_buttons = ~sys.flag.lock_buttons; - + // Show "buttons are locked/unlocked" message synchronously with next second tick message.flag.prepare = 1; if (sys.flag.lock_buttons) message.flag.type_locked = 1; else message.flag.type_unlocked = 1; - + // Reset button lock counter button_lock_counter = 0; } @@ -596,13 +596,13 @@ __interrupt void TIMER0_A0_ISR(void) { // Reset button lock counter button_lock_counter = 0; - - if (BUTTON_STAR_IS_PRESSED) + + if (BUTTON_STAR_IS_PRESSED) { sButton.star_timeout++; - + // Check if button was held low for some seconds - if (sButton.star_timeout > LEFT_BUTTON_LONG_TIME) + if (sButton.star_timeout > LEFT_BUTTON_LONG_TIME) { button.flag.star_long = 1; sButton.star_timeout = 0; @@ -612,13 +612,13 @@ __interrupt void TIMER0_A0_ISR(void) { sButton.star_timeout = 0; } - - if (BUTTON_NUM_IS_PRESSED) + + if (BUTTON_NUM_IS_PRESSED) { sButton.num_timeout++; - + // Check if button was held low for some seconds - if (sButton.num_timeout > LEFT_BUTTON_LONG_TIME) + if (sButton.num_timeout > LEFT_BUTTON_LONG_TIME) { button.flag.num_long = 1; sButton.num_timeout = 0; @@ -629,9 +629,9 @@ __interrupt void TIMER0_A0_ISR(void) sButton.num_timeout = 0; } } - + // Exit from LPM3 on RETI - _BIC_SR_IRQ(LPM3_bits); + _BIC_SR_IRQ(LPM3_bits); } @@ -646,7 +646,7 @@ __interrupt void TIMER0_A0_ISR(void) // @param none // @return none // ************************************************************************************************* -//pfs +//pfs #ifdef __GNUC__ #include interrupt (TIMER0_A1_VECTOR) TIMER0_A1_5_ISR(void) @@ -656,7 +656,7 @@ __interrupt void TIMER0_A1_5_ISR(void) #endif { u16 value; - + switch (TA0IV) { //pfs @@ -669,10 +669,10 @@ __interrupt void TIMER0_A1_5_ISR(void) #ifdef CONFIG_SIDEREAL // Timer0_A1 Used for sidereal time until CCR0 becomes free case 0x02: // Timer0_A1 handler - // Disable IE + // Disable IE TA0CCTL1 &= ~CCIE; - // Reset IRQ flag - TA0CCTL1 &= ~CCIFG; + // Reset IRQ flag + TA0CCTL1 &= ~CCIFG; //for sidereal time we need 32768/1.00273790935=32678.529149 clock cycles for one second //32678.5 clock cycles gives a deviation of ~0.9e-7~0.1s/day which is likely less than the ozillator deviation if(sSidereal_time.second & 1) @@ -683,12 +683,12 @@ __interrupt void TIMER0_A1_5_ISR(void) { TA0CCR1+=32679; } - // Enable IE + // Enable IE TA0CCTL1 |= CCIE; - + // Add 1 second to global time sidereal_clock_tick(); - + // Set clock update flag display.flag.update_sidereal_time = 1; break; @@ -708,49 +708,49 @@ __interrupt void TIMER0_A1_5_ISR(void) fptr_Timer0_A1_function(); break; #endif - // Timer0_A2 1/1 or 1/100 sec Stopwatch + // Timer0_A2 1/1 or 1/100 sec Stopwatch case 0x04: // Timer0_A2 handler - // Disable IE + // Disable IE TA0CCTL2 &= ~CCIE; - // Reset IRQ flag - TA0CCTL2 &= ~CCIFG; + // Reset IRQ flag + TA0CCTL2 &= ~CCIFG; // Load CCR register with next capture point #ifdef CONFIG_STOP_WATCH update_stopwatch_timer(); #endif - // Enable timer interrupt - TA0CCTL2 |= CCIE; + // Enable timer interrupt + TA0CCTL2 |= CCIE; // Increase stopwatch counter #ifdef CONFIG_STOP_WATCH stopwatch_tick(); #endif break; - - // Timer0_A3 Configurable periodic IRQ (used by button_repeat and buzzer) - case 0x06: // Disable IE + + // Timer0_A3 Configurable periodic IRQ (used by button_repeat and buzzer) + case 0x06: // Disable IE TA0CCTL3 &= ~CCIE; - // Reset IRQ flag - TA0CCTL3 &= ~CCIFG; + // Reset IRQ flag + TA0CCTL3 &= ~CCIFG; // Store new value in CCR value = TA0R + sTimer.timer0_A3_ticks; //timer0_A3_ticks_g; // Load CCR register with next capture point - TA0CCR3 = value; - // Enable timer interrupt - TA0CCTL3 |= CCIE; + TA0CCR3 = value; + // Enable timer interrupt + TA0CCTL3 |= CCIE; // Call function handler fptr_Timer0_A3_function(); break; - - // Timer0_A4 One-time delay - case 0x08: // Disable IE + + // Timer0_A4 One-time delay + case 0x08: // Disable IE TA0CCTL4 &= ~CCIE; - // Reset IRQ flag - TA0CCTL4 &= ~CCIFG; + // Reset IRQ flag + TA0CCTL4 &= ~CCIFG; // Set delay over flag sys.flag.delay_over = 1; break; } - + // Exit from LPM3 on RETI - _BIC_SR_IRQ(LPM3_bits); + _BIC_SR_IRQ(LPM3_bits); } diff --git a/driver/vti_as.c b/driver/vti_as.c index 548a603..1fabc58 100644 --- a/driver/vti_as.c +++ b/driver/vti_as.c @@ -1,34 +1,34 @@ // ************************************************************************************************* // -// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ -// -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions +// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ +// +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions // are met: -// -// Redistributions of source code must retain the above copyright +// +// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the // distribution. -// +// // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ************************************************************************************************* @@ -115,7 +115,7 @@ u8 as_ok; // ************************************************************************************************* void as_init(void) { -#ifdef AS_DISCONNECT +#ifdef AS_DISCONNECT // Deactivate connection to acceleration sensor AS_PWR_OUT &= ~AS_PWR_PIN; // Power off AS_INT_OUT &= ~AS_INT_PIN; // Pin to low to avoid floating pins @@ -130,10 +130,10 @@ void as_init(void) AS_SPI_DIR &= ~AS_SDI_PIN; // Input AS_SPI_DIR |= AS_SDO_PIN + AS_SCK_PIN; // Output AS_SPI_SEL |= AS_SDO_PIN + AS_SDI_PIN + AS_SCK_PIN; // Port pins to SDO, SDI and SCK function - AS_CSN_OUT |= AS_CSN_PIN; // CSN=1 - AS_CSN_DIR |= AS_CSN_PIN; // - AS_PWR_OUT |= AS_PWR_PIN; // VDD=1 - AS_PWR_DIR |= AS_PWR_PIN; // + AS_CSN_OUT |= AS_CSN_PIN; // CSN=1 + AS_CSN_DIR |= AS_CSN_PIN; // + AS_PWR_OUT |= AS_PWR_PIN; // VDD=1 + AS_PWR_DIR |= AS_PWR_PIN; // #endif // Reset global sensor flag @@ -151,7 +151,7 @@ void as_start(void) { volatile u16 Counter_u16; u8 bConfig;//, bStatus; - + // Initialize SPI interface to acceleration sensor AS_SPI_CTL0 |= UCSYNC | UCMST | UCMSB // SPI master, 8 data bits, MSB first, | UCCKPH; // clock idle low, data output on falling edge @@ -159,12 +159,12 @@ void as_start(void) AS_SPI_BR0 = AS_BR_DIVIDER; // Low byte of division factor for baud rate AS_SPI_BR1 = 0x00; // High byte of division factor for baud rate AS_SPI_CTL1 &= ~UCSWRST; // Start SPI hardware - + // Initialize interrupt pin for data read out from acceleration sensor AS_INT_IES &= ~AS_INT_PIN; // Interrupt on rising edge -#ifdef AS_DISCONNECT - // Enable interrupt +#ifdef AS_DISCONNECT + // Enable interrupt AS_INT_DIR &= ~AS_INT_PIN; // Switch INT pin to input AS_SPI_DIR &= ~AS_SDI_PIN; // Switch SDI pin to input AS_SPI_REN |= AS_SDI_PIN; // Pulldown on SDI pin @@ -175,11 +175,11 @@ void as_start(void) // Delay of >5ms required between switching on power and configuring sensor Timer0_A4_Delay(CONV_MS_TO_TICKS(10)); - + // Initialize interrupt pin for data read out from acceleration sensor AS_INT_IFG &= ~AS_INT_PIN; // Reset flag AS_INT_IE |= AS_INT_PIN; // Enable interrupt - + // Configure sensor and start to sample data #if (AS_RANGE == 2) bConfig = 0x80; @@ -202,19 +202,19 @@ void as_start(void) #error "Sample rate not supported" #endif #else - #error "Measurement range not supported" -#endif + #error "Measurement range not supported" +#endif // Reset sensor - as_write_register(0x04, 0x02); - as_write_register(0x04, 0x0A); - as_write_register(0x04, 0x04); - + as_write_register(0x04, 0x02); + as_write_register(0x04, 0x0A); + as_write_register(0x04, 0x04); + // Wait 5 ms before starting sensor output Timer0_A4_Delay(CONV_MS_TO_TICKS(5)); - + // Set 2g measurement range, start to output data with 100Hz rate - as_write_register(0x02, bConfig); + as_write_register(0x02, bConfig); } @@ -227,7 +227,7 @@ void as_start(void) // ************************************************************************************************* void as_stop(void) { - // Disable interrupt + // Disable interrupt AS_INT_IE &= ~AS_INT_PIN; // Disable interrupt #ifdef AS_DISCONNECT @@ -242,9 +242,9 @@ void as_stop(void) AS_CSN_DIR |= AS_CSN_PIN; // Pin to output to avoid floating pins #else // Reset sensor -> sensor to powerdown - as_write_register(0x04, 0x02); - as_write_register(0x04, 0x0A); - as_write_register(0x04, 0x04); + as_write_register(0x04, 0x02); + as_write_register(0x04, 0x0A); + as_write_register(0x04, 0x04); #endif } @@ -259,7 +259,7 @@ u8 as_read_register(u8 bAddress) { u8 bResult; u16 timeout; - + // Exit function if an error was detected previously if (!as_ok) return (0); @@ -271,24 +271,24 @@ u8 as_read_register(u8 bAddress) bResult = AS_RX_BUFFER; // Read RX buffer just to clear interrupt flag AS_TX_BUFFER = bAddress; // Write address to TX buffer - + timeout = SPI_TIMEOUT; while (!(AS_IRQ_REG & AS_RX_IFG) && (--timeout>0)); // Wait until new data was written into RX buffer if (timeout == 0) { - as_ok = 0; - return (0); + as_ok = 0; + return (0); } bResult = AS_RX_BUFFER; // Read RX buffer just to clear interrupt flag AS_TX_BUFFER = 0; // Write dummy data to TX buffer - + timeout = SPI_TIMEOUT; while (!(AS_IRQ_REG & AS_RX_IFG) && (--timeout>0)); // Wait until new data was written into RX buffer if (timeout == 0) { - as_ok = 0; - return (0); + as_ok = 0; + return (0); } bResult = AS_RX_BUFFER; // Read RX buffer @@ -302,35 +302,35 @@ u8 as_read_register(u8 bAddress) // ************************************************************************************************* // @fn as_write_register -// @brief Write a byte to the acceleration sensor +// @brief Write a byte to the acceleration sensor // @param u8 bAddress Register address // u8 bData Data to write -// @return u8 +// @return u8 // ************************************************************************************************* u8 as_write_register(u8 bAddress, u8 bData) { u8 bResult; u16 timeout; - + // Exit function if an error was detected previously if (!as_ok) return (0); bAddress <<= 2; // Address to be shifted left by 1 bAddress |= BIT1; // RW bit to be set - + AS_SPI_REN &= ~AS_SDI_PIN; // Pulldown on SDI pin not required AS_CSN_OUT &= ~AS_CSN_PIN; // Select acceleration sensor bResult = AS_RX_BUFFER; // Read RX buffer just to clear interrupt flag AS_TX_BUFFER = bAddress; // Write address to TX buffer - + timeout = SPI_TIMEOUT; while (!(AS_IRQ_REG & AS_RX_IFG) && (--timeout>0)); // Wait until new data was written into RX buffer if (timeout == 0) { - as_ok = 0; - return (0); + as_ok = 0; + return (0); } bResult = AS_RX_BUFFER; // Read RX buffer just to clear interrupt flag @@ -338,10 +338,10 @@ u8 as_write_register(u8 bAddress, u8 bData) timeout = SPI_TIMEOUT; while (!(AS_IRQ_REG & AS_RX_IFG) && (--timeout>0)); // Wait until new data was written into RX buffer - if (timeout == 0) + if (timeout == 0) { - as_ok = 0; - return (0); + as_ok = 0; + return (0); } bResult = AS_RX_BUFFER; // Read RX buffer @@ -362,8 +362,8 @@ void as_get_data(u8 * data) { // Exit if sensor is not powered up if ((AS_PWR_OUT & AS_PWR_PIN) != AS_PWR_PIN) return; - - // Store X/Y/Z acceleration data in buffer + + // Store X/Y/Z acceleration data in buffer *(data+0) = as_read_register(0x06); *(data+1) = as_read_register(0x07); *(data+2) = as_read_register(0x08); diff --git a/driver/vti_ps.c b/driver/vti_ps.c index ca07587..ed81ae2 100644 --- a/driver/vti_ps.c +++ b/driver/vti_ps.c @@ -1,34 +1,34 @@ // ************************************************************************************************* // -// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ -// -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions +// Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ +// +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions // are met: -// -// Redistributions of source code must retain the above copyright +// +// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the // distribution. -// +// // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ************************************************************************************************* @@ -96,12 +96,12 @@ u8 ps_ok; void ps_init(void) { volatile u8 success, status, eeprom, timeout; - + PS_INT_DIR &= ~PS_INT_PIN; // DRDY is input PS_INT_IES &= ~PS_INT_PIN; // Interrupt on DRDY rising edge PS_TWI_OUT |= PS_SCL_PIN + PS_SDA_PIN; // SCL and SDA are outputs by default PS_TWI_DIR |= PS_SCL_PIN + PS_SDA_PIN; // SCL and SDA are outputs by default - + // Reset global ps_ok flag ps_ok = 0; @@ -109,16 +109,16 @@ void ps_init(void) Timer0_A4_Delay(CONV_MS_TO_TICKS(100)); // Reset pressure sensor -> powerdown sensor - success = ps_write_register(0x06, 0x01); + success = ps_write_register(0x06, 0x01); - // 100msec delay + // 100msec delay Timer0_A4_Delay(CONV_MS_TO_TICKS(100)); // Check if STATUS register BIT0 is cleared status = ps_read_register(0x07, PS_TWI_8BIT_ACCESS); - if (((status & BIT0) == 0) && (status != 0)) + if (((status & BIT0) == 0) && (status != 0)) { - // Check EEPROM checksum in DATARD8 register + // Check EEPROM checksum in DATARD8 register eeprom = ps_read_register(0x7F, PS_TWI_8BIT_ACCESS); if (eeprom == 0x01) ps_ok = 1; else ps_ok = 0; @@ -134,8 +134,8 @@ void ps_init(void) // ************************************************************************************************* void ps_start(void) { - // Start sampling data in ultra low power mode - ps_write_register(0x03, 0x0B); + // Start sampling data in ultra low power mode + ps_write_register(0x03, 0x0B); } @@ -149,7 +149,7 @@ void ps_start(void) void ps_stop(void) { // Put sensor to standby - ps_write_register(0x03, 0x00); + ps_write_register(0x03, 0x00); } @@ -164,7 +164,7 @@ void ps_stop(void) u8 ps_twi_sda(u8 condition) { u8 sda = 0; - + if (condition == PS_TWI_SEND_START) { PS_TWI_SDA_OUT; // SDA is output @@ -193,9 +193,9 @@ u8 ps_twi_sda(u8 condition) PS_TWI_SDA_OUT; // SDA is output PS_TWI_SDA_LO; twi_delay(); - PS_TWI_SCL_LO; + PS_TWI_SCL_LO; twi_delay(); - PS_TWI_SCL_HI; + PS_TWI_SCL_HI; twi_delay(); PS_TWI_SDA_HI; // SDA 0-1 transition while SCL=1 twi_delay(); @@ -203,14 +203,14 @@ u8 ps_twi_sda(u8 condition) else if (condition == PS_TWI_CHECK_ACK) { PS_TWI_SDA_IN; // SDA is input - PS_TWI_SCL_LO; + PS_TWI_SCL_LO; twi_delay(); - PS_TWI_SCL_HI; + PS_TWI_SCL_HI; twi_delay(); sda = PS_TWI_IN & PS_SDA_PIN; - PS_TWI_SCL_LO; + PS_TWI_SCL_LO; } - + // Return value will only be evaluated when checking device ACK return (sda == 0); } @@ -219,7 +219,7 @@ u8 ps_twi_sda(u8 condition) // ************************************************************************************************* // @fn twi_delay -// @brief Delay between TWI signal edges. +// @brief Delay between TWI signal edges. // @param none // @return none // ************************************************************************************************* @@ -238,12 +238,12 @@ void twi_delay(void) void ps_twi_write(u8 data) { u8 i, mask; - + // Set mask byte to 10000000b mask = BIT0<<7; - + PS_TWI_SDA_OUT; // SDA is output - + for (i=8; i>0; i--) { PS_TWI_SCL_LO; // SCL=0 @@ -251,19 +251,19 @@ void ps_twi_write(u8 data) { PS_TWI_SDA_HI; // SDA=1 } - else + else { - PS_TWI_SDA_LO; // SDA=0 + PS_TWI_SDA_LO; // SDA=0 } mask = mask >> 1; twi_delay(); PS_TWI_SCL_HI; // SCL=1 twi_delay(); } - + PS_TWI_SCL_LO; // SCL=0 PS_TWI_SDA_IN; // SDA is input -} +} // ************************************************************************************************* @@ -276,25 +276,25 @@ u8 ps_twi_read(u8 ack) { u8 i; u8 data = 0; - + PS_TWI_SDA_IN; // SDA is input - + for (i=0; i<8; i++) { PS_TWI_SCL_LO; // SCL=0 twi_delay(); PS_TWI_SCL_HI; // SCL=0 twi_delay(); - - // Shift captured bits to left - data = data << 1; + + // Shift captured bits to left + data = data << 1; // Capture new bit - if ((PS_TWI_IN & PS_SDA_PIN) == PS_SDA_PIN) data |= BIT0; + if ((PS_TWI_IN & PS_SDA_PIN) == PS_SDA_PIN) data |= BIT0; } PS_TWI_SDA_OUT; // SDA is output - + // 1 aditional clock phase to generate master ACK PS_TWI_SCL_LO; // SCL=0 if (ack == 1) PS_TWI_SDA_LO // Send ack -> continue read @@ -303,9 +303,9 @@ u8 ps_twi_read(u8 ack) PS_TWI_SCL_HI; // SCL=0 twi_delay(); PS_TWI_SCL_LO; - + return (data); -} +} @@ -314,27 +314,27 @@ u8 ps_twi_read(u8 ack) // @brief Write a byte to the pressure sensor // @param u8 address Register address // u8 data Data to write -// @return u8 +// @return u8 // ************************************************************************************************* u8 ps_write_register(u8 address, u8 data) { volatile u8 success; ps_twi_sda(PS_TWI_SEND_START); // Generate start condition - + ps_twi_write((0x11<<1) | PS_TWI_WRITE); // Send 7bit device address 0x11 + write bit '0' success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device if (!success) return (0); - + ps_twi_write(address); // Send 8bit register address success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device if (!success) return (0); - + ps_twi_write(data); // Send 8bit data to register success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device // Slave does not send this ACK // if (!success) return (0); - + ps_twi_sda(PS_TWI_SEND_STOP); // Generate stop condition return (1); @@ -358,7 +358,7 @@ u16 ps_read_register(u8 address, u8 mode) ps_twi_write((0x11<<1) | PS_TWI_WRITE); // Send 7bit device address 0x11 + write bit '0' success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device if (!success) return (0); - + ps_twi_write(address); // Send 8bit register address success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device if (!success) return (0); @@ -368,7 +368,7 @@ u16 ps_read_register(u8 address, u8 mode) ps_twi_write((0x11<<1) | PS_TWI_READ); // Send 7bit device address 0x11 + read bit '1' success = ps_twi_sda(PS_TWI_CHECK_ACK); // Check ACK from device if (!success) return (0); - + if (mode == PS_TWI_16BIT_ACCESS) { data = ps_twi_read(1) << 8; // Read MSB 8bit data from register @@ -377,8 +377,8 @@ u16 ps_read_register(u8 address, u8 mode) else { data = ps_twi_read(0); // Read 8bit data from register - } - + } + ps_twi_sda(PS_TWI_SEND_STOP); // Generate stop condition return (data); @@ -395,17 +395,17 @@ u16 ps_read_register(u8 address, u8 mode) u32 ps_get_pa(void) { volatile u32 data = 0; - + // Get 3 MSB from DATARD8 register data = ps_read_register(0x7F, PS_TWI_8BIT_ACCESS); data = ((data & 0x07) << 8) << 8; // Get 16 LSB from DATARD16 register data |= ps_read_register(0x80, PS_TWI_16BIT_ACCESS); - + // Convert decimal value to Pa data = (data >> 2); - + return (data); } @@ -422,12 +422,12 @@ u16 ps_get_temp(void) u16 temp = 0; u8 is_negative = 0; u16 kelvin; - + // Get 13 bit from TEMPOUT register data = ps_read_register(0x81, PS_TWI_16BIT_ACCESS); - + // Convert negative temperatures - if ((data & BIT(13)) == BIT(13)) + if ((data & BIT(13)) == BIT(13)) { // Sign extend temperature data |= 0xC000; @@ -438,11 +438,11 @@ u16 ps_get_temp(void) } temp = data / 2; - + // Convert from °C to °K if (is_negative) kelvin = 2732 - temp; else kelvin = temp + 2732; - + return (kelvin); } @@ -530,37 +530,37 @@ void update_pressure_table(s16 href, u32 p_meas, u16 t_meas) #ifndef FIXEDPOINT const float Invt00 = 0.003470415; const float coefp = 0.00006; - volatile float p_fact; + volatile float p_fact; volatile float p_noll; volatile float hnoll; volatile float h_low = 0; volatile float t0; u8 i; - + // Typecast arguments volatile float fl_href = href; volatile float fl_p_meas = (float)p_meas/100; // Convert from Pa to hPa volatile float fl_t_meas = (float)t_meas/10; // Convert from 10°K to 1°K t0 = fl_t_meas + (0.0065*fl_href); - + hnoll = fl_href/(t0*Invt00); - + for (i=0; i<=15; i++) { if (h0[i] > hnoll) break; - h_low = h0[i]; + h_low = h0[i]; } - + p_noll = (float)(hnoll - h_low)*(1 - (hnoll - (float)h0[i])* coefp)*((float)p0[i] - (float)p0[i-1])/((float)h0[i] - h_low) + (float)p0[i-1]; // Calculate multiplicator p_fact = fl_p_meas/p_noll; - + // Apply correction factor to pressure table for (i=0; i<=16; i++) { - p[i] = p0[i]*p_fact; + p[i] = p0[i]*p_fact; } #else // Note: a user-provided sea-level reference pressure in mbar as used by pilots @@ -607,18 +607,18 @@ s16 conv_pa_to_meter(u32 p_meas, u16 t_meas) // Typecast arguments volatile float fl_p_meas = (float)p_meas/100; // Convert from Pa to hPa volatile float fl_t_meas = (float)t_meas/10; // Convert from 10°K to 1°K - + for (i=0; i<=16; i++) { if (p[i] < fl_p_meas) break; p_low = p[i]; } - - if (i==0) + + if (i==0) { hnoll = (float)(fl_p_meas - p[0])/(p[1] - p[0])*((float)(h0[1] - h0[0])); } - else if (i<15) + else if (i<15) { hnoll = (float)(fl_p_meas - p_low)*(1 - (fl_p_meas - p[i])* coef2)/(p[i] - p_low)*((float)(h0[i] - h0[i-1])) + h0[i-1]; } @@ -630,12 +630,12 @@ s16 conv_pa_to_meter(u32 p_meas, u16 t_meas) { hnoll = (float)(fl_p_meas - p[16])/(p[16] - p[15])*((float)(h0[16] - h0[15])) + h0[16]; } - + // Compensate temperature error t0 = fl_t_meas/(1 - hnoll*Invt00*0.0065); fl_h = Invt00*t0*hnoll; h = (u16)fl_h; - + return (h); } #else diff --git a/ezchronos.c b/ezchronos.c index a02fd67..31d2798 100644 --- a/ezchronos.c +++ b/ezchronos.c @@ -174,17 +174,17 @@ int main(void) while(1) { // When idle go to LPM3 - idle_loop(); + idle_loop(); - // Process wake-up events - if (button.all_flags || sys.all_flags) wakeup_event(); + // Process wake-up events + if (button.all_flags || sys.all_flags) wakeup_event(); - // Process actions requested by logic modules - if (request.all_flags) process_requests(); + // Process actions requested by logic modules + if (request.all_flags) process_requests(); - // Before going to LPM3, update display - if (display.all_flags) display_update(); - } + // Before going to LPM3, update display + if (display.all_flags) display_update(); + } } @@ -220,7 +220,7 @@ void init_application(void) // --------------------------------------------------------------------- // Enable 32kHz ACLK P5SEL |= 0x03; // Select XIN, XOUT on P5.0 and P5.1 - UCSCTL6 &= ~XT1OFF; // XT1 On, Highest drive strength + UCSCTL6 &= ~XT1OFF; // XT1 On, Highest drive strength UCSCTL6 |= XCAP_3; // Internal load cap UCSCTL3 = SELA__XT1CLK; // Select XT1 as FLL reference diff --git a/gcc/intrinsics.c b/gcc/intrinsics.c index d841903..bfd7f23 100644 --- a/gcc/intrinsics.c +++ b/gcc/intrinsics.c @@ -16,16 +16,16 @@ void __delay_cycles(unsigned long __cycles) { // divide by eight asm volatile("clrc"); - asm volatile("rra.w %[src]" - : [src] "=r" (__cycles) + asm volatile("rra.w %[src]" + : [src] "=r" (__cycles) : "[src]" (__cycles) ); asm volatile("clrc"); - asm volatile("rra.w %[src]" - : [src] "=r" (__cycles) + asm volatile("rra.w %[src]" + : [src] "=r" (__cycles) : "[src]" (__cycles) ); asm volatile("clrc"); - asm volatile("rra.w %[src]" - : [src] "=r" (__cycles) + asm volatile("rra.w %[src]" + : [src] "=r" (__cycles) : "[src]" (__cycles) ); asm volatile("DelayLoop:"); asm volatile("nop"); // add nops to increase loop to eight clock cycles @@ -34,7 +34,7 @@ void __delay_cycles(unsigned long __cycles) asm volatile("nop"); asm volatile("nop"); asm volatile("dec.w %[src]" - : [src] "=r" (__cycles) + : [src] "=r" (__cycles) : "[src]" (__cycles)); asm volatile("jne DelayLoop"); } @@ -45,11 +45,11 @@ void __set_interrupt_state(istate_t state) __asm__("bis %0,r2" : : "ir" ((uint16_t) state)); } - + //__get_interrupt_state used in bsp_msp430_defs.h, rf1a.c istate_t __get_interrupt_state(void) { return(READ_SR&0x0008); } - - + + diff --git a/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c b/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c index ce29285..8e6a16a 100644 --- a/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c +++ b/simpliciti/Components/mrfi/radios/family5/mrfi_radio.c @@ -244,7 +244,7 @@ const uint8_t mrfiRadioCfg[][2] = * The static assert below ensures that there is no mismatch. */ // [BM] Changed channel assignment to comply with local regulations -#ifdef ISM_EU +#ifdef ISM_EU static const uint8_t mrfiLogicalChanTable[] = { 0, @@ -269,7 +269,7 @@ static const uint8_t mrfiLogicalChanTable[] = 50, 80, 110 - }; + }; #else #error "Wrong ISM band specified (valid are ISM_LF, ISM_EU and ISM_US)" #endif @@ -306,8 +306,8 @@ static const uint8_t mrfiRFPowerTable[] = // [BM] Changed default output power to comply with dongle settings 0x0F, 0x27, -// [BM] Increase output power from -0.3dBm to +1.4dBm (433MHz) / +1.1dBm (868MHz) / +1.3dBm (915MHz) to compensate antenna loss -#ifdef ISM_EU +// [BM] Increase output power from -0.3dBm to +1.4dBm (433MHz) / +1.1dBm (868MHz) / +1.3dBm (915MHz) to compensate antenna loss +#ifdef ISM_EU 0x8C #else #ifdef ISM_US @@ -481,7 +481,7 @@ void MRFI_Init(void) // [BM] Apply global frequency offset to FSCTRL0 MRFI_STROBE_IDLE_AND_WAIT(); MRFI_RADIO_REG_WRITE(FSCTRL0, rf_frequoffset); - + /* set default channel */ MRFI_SetLogicalChannel( 0 ); From 81e0e609f4c464de6dd43dbe97cb0d8f485961ed Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Sun, 22 Mar 2015 03:38:49 +0100 Subject: [PATCH 7/7] Silent status. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b1671c3..c083f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ tags +TAGS *.pyc *.swp *.o .gitignore build/ *.map +