Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added accelerometer and pressure drivers for white PCB, and new modules. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### emacs backup files
*~
contrib/*~
drivers/*~
modules/*~
toolchains/*~
tools/*~

### Temp files ###
nohup.out
*.[oa]
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Edit this with your compiler's path:
MSP430_TI = /root/ti/msp430-gcc

SUBDIRS = drivers modules

include Common.mk
Expand Down Expand Up @@ -56,9 +59,10 @@ $(OBJS): openchronos.cflags
#
# Top rules

# Strangely enough libm must be linked last...
openchronos.elf: $(OBJS)
@echo "\n>> Building $@ as target $(TARGET)"
@$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) -o $@ $+
@$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) -o $@ $+ -lm

openchronos.txt: openchronos.elf
$(PYTHON) tools/memory.py -i $< -o $@
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
OpenChronos-ng-elf fork
=======================

Added features
--------------

* Added support for BMA250 accelerometer and BMP85 pressure and temperature sensor (packed in the white PCB eZ430-Chronos)
* Added Black/White PCB dependencies in config.py
* Added new modules
* Music module now plays a shorter tune (Nokia tune instead of Super Mario Bros. theme).

New modules
-----------

* Altimeter module for white PCB
* Accelerometer module for white PCB
* Boiling point calculator for white PCB
* Cricket's chirp calculator (any PCB)
* Scrolling hello world (any PCB)
* Speed of sound calculator for white PCB
* Step counter calculator for white PCB.

GENERAL INFORMATION
===================

Expand Down
65 changes: 32 additions & 33 deletions boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define PORTS_BTN_DOWN_PIN (BIT0)


inline void initialize_aclk()
void initialize_aclk()
{
/* Select XIN, XOUT on P5.0 and P5.1 */
P5SEL |= 0x03;
Expand All @@ -64,7 +64,7 @@ inline void initialize_aclk()
UCSCTL4 = SELA__XT1CLK | SELS__DCOCLKDIV | SELM__DCOCLKDIV;
}

inline void initialize_cpu_12mhz()
void initialize_cpu_12mhz()
{
/* Disable the FLL control loop */
_BIS_SR(SCG0);
Expand All @@ -76,26 +76,26 @@ inline void initialize_cpu_12mhz()
UCSCTL1 = DCORSEL_5;

/* Set DCO Multiplier */
UCSCTL2 = FLLD_1 + 0x16E; // (32768 * 0x16e) almost 12 mhz
UCSCTL2 = FLLD_1 + 0x16E; // (32768 * 0x16e) almost 12 mhz
_BIC_SR(SCG0);

/* Worst-case settling time for the DCO when the DCO range bits have been
changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
UG for optimization.
32 x 32 x 12 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle */
changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
UG for optimization.
32 x 32 x 12 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle */
__delay_cycles(375000);

/* Loop until XT1 & DCO stabilizes, use do-while to insure that
body is executed at least once */
body is executed at least once */
do {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);

/* Clear fault flags */
SFRIFG1 &= ~OFIFG;
/* Clear fault flags */
SFRIFG1 &= ~OFIFG;
} while ((SFRIFG1 & OFIFG));
}

inline void initialize_buttons()
void initialize_buttons()
{
/* Set button ports to input */
P2DIR &= ~ALL_BUTTONS;
Expand All @@ -105,7 +105,7 @@ inline void initialize_buttons()
P2REN |= ALL_BUTTONS;
}

inline void initialize_lcd()
void initialize_lcd()
{
/* clear entire display memory */
LCDBMEMCTL |= LCDCLRBM + LCDCLRM;
Expand All @@ -120,11 +120,11 @@ inline void initialize_lcd()
/* LCD_FREQ = ACLK/8/8 = 512Hz */
/* Frame frequency = 512Hz/2/4 = 64Hz, LCD mux 4, LCD on */
LCDBCTL0 = (LCDDIV0 + LCDDIV1 + LCDDIV2)
| (LCDPRE0 + LCDPRE1) | LCD4MUX | LCDON;
| (LCDPRE0 + LCDPRE1) | LCD4MUX | LCDON;

/* LCB_BLK_FREQ = ACLK/8/2048 = 2Hz */
LCDBBLKCTL = LCDBLKPRE1 | LCDBLKDIV0 | LCDBLKDIV1
| LCDBLKDIV2 | LCDBLKMOD0;
| LCDBLKDIV2 | LCDBLKMOD0;

/* I/O to COM outputs */
P5SEL |= (BIT5 | BIT6 | BIT7);
Expand All @@ -143,7 +143,7 @@ inline void initialize_lcd()
#endif
}

inline void jump_to_rfbsl()
void jump_to_rfbsl()
{
/* clear display memory (useful to know if rfbsl failed) */
LCDBMEMCTL |= LCDCLRBM + LCDCLRM;
Expand All @@ -154,7 +154,7 @@ inline void jump_to_rfbsl()


/* put bootmenu in the crt_0042 section which is executed before main */
__attribute__((naked, section(".crt_0042"), used))
__attribute__ ((naked, section(".crt_0042"), used))
static void crt_0042(void)
{
wdt_stop();
Expand All @@ -164,9 +164,9 @@ static void crt_0042(void)

/* Set global high power request enable */
{
PMMCTL0_H = 0xA5;
PMMCTL0_L |= PMMHPMRE;
PMMCTL0_H = 0x00;
PMMCTL0_H = 0xA5;
PMMCTL0_L |= PMMHPMRE;
PMMCTL0_H = 0x00;
}

/* Enable 32kHz ACLK */
Expand All @@ -182,41 +182,40 @@ static void crt_0042(void)
initialize_lcd();

/* Write 'boot' to the screen without using display functions */
LCDM2 = 199; /* 'b' */
LCDM3 = 198; /* 'o' */
LCDM4 = 198; /* 'o' */
LCDM6 = 135; /* 't' */
LCDM2 = 199; /* 'b' */
LCDM3 = 198; /* 'o' */
LCDM4 = 198; /* 'o' */
LCDM6 = 135; /* 't' */

/* configure watchdog interrupt timer, used for polling buttons */
{
/* ACLK timer source, 250ms timer mode, resume watchdog */
WDTCTL = WDT_ADLY_250;
/* ACLK timer source, 250ms timer mode, resume watchdog */
WDTCTL = WDT_ADLY_250;

/* Enable watchdog timer interrupts */
SFRIE1 |= WDTIE;
/* Enable watchdog timer interrupts */
SFRIE1 |= WDTIE;
}

/* Enable global interrupts */
__enable_interrupt();

/* loop if no button is pressed, enter RFBSL if backlight is pressed */
do {
_BIS_SR(LPM3_bits | GIE);
__no_operation();
_BIS_SR(LPM3_bits | GIE);
__no_operation();

if ((P2IN & ALL_BUTTONS) == PORTS_BTN_DOWN_PIN)
jump_to_rfbsl();
if ((P2IN & ALL_BUTTONS) == PORTS_BTN_DOWN_PIN)
jump_to_rfbsl();

} while ((P2IN & ALL_BUTTONS) == 0);

/* Disable them again, they will be re-enabled later on in main() */
__disable_interrupt();
}

__attribute__((interrupt(WDT_VECTOR)))
__attribute__ ((interrupt(WDT_VECTOR)))
void WDT_ISR(void)
{
/* exit from LPM3 after interrupt */
_BIC_SR_IRQ(LPM3_bits);
}

18 changes: 9 additions & 9 deletions contrib/ChronosTool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###################################################################################################
# ChronosTool.py
Expand Down Expand Up @@ -245,7 +245,7 @@ def __del__( self ):
self.device.close

def send( self, cmd ):
self.device.write( cmd.tostr() )
self.device.write( cmd.tobytes() )
time.sleep( 0.015 )
if opt.verbose:
print >> sys.stderr, 'SENT:', cmd.tohex()
Expand Down Expand Up @@ -406,7 +406,7 @@ def spl_sync( self, dt=[], celsius=0, meters=0 ):
time.sleep(2)
if not dt:
dt = datetime.datetime.now()
print "Syncing Time %s, Temp %s C, and altitude %s m)" % (str(dt), str(celsius), str(meters))
print("Syncing Time %s, Temp %s C, and altitude %s m)") % (str(dt), str(celsius), str(meters))

payload = bytearray( 0x13 )
payload[0x00] = 0x03
Expand All @@ -427,7 +427,7 @@ def spl_sync( self, dt=[], celsius=0, meters=0 ):
self.sendcmd( 0x31, payload ) #BM_SYNC_SendCommand
time.sleep( 2 )
self.spl_stop()
print "Synced!"
print("Synced!")

def transmitburst( self, data ):
self.wbsl_start()
Expand Down Expand Up @@ -649,17 +649,17 @@ def wbsl_download( self, txtdata ):
30 1D
q""")
data = CBMdata()
print "Reading firmware file"
print("Reading firmware file")
data.importtxt( txtdata )

raw_input("Hit enter to start update process. (or Ctrl+C to exit)")

print "Ready to update. Set your watch in rfbsl \"open\" mode."
print("Ready to update. Set your watch in rfbsl \"open\" mode.")
self.transmitburst( updater )
print "Sending new firmware.."
print("Sending new firmware..")
self.transmitburst( data )
time.sleep( 1 )
print "Done!"
print("Done!")

###################################################################################################
# main
Expand Down Expand Up @@ -747,7 +747,7 @@ def wbsl_download( self, txtdata ):
while True:
data = bm.spl_getaccel()
if data[0]:
print str( data[1] ) + " " + str( data[2] ) + " " + str( data[3] )
print(str( data[1] ) + " " + str( data[2] ) + " " + str( data[3] ))
else:
print >> sys.stderr, "ERROR: invalid command:", command
sys.exit( 4 )
Expand Down
2 changes: 1 addition & 1 deletion contrib/rtttl2bin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Aljaž Srebrnič <a2piratesoft@gmail.com>
Expand Down
Loading