Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hexanome/setre2013
Browse files Browse the repository at this point in the history
  • Loading branch information
Duranton Fabien committed Feb 19, 2013
2 parents f72e30d + eb3bfeb commit 54a4f04
Show file tree
Hide file tree
Showing 57 changed files with 18,831 additions and 110 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
*.app
*.elf

# Log/Trace files
*.log
*.trc

# Others
*.lst
11 changes: 9 additions & 2 deletions drivers/bargraph/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# makfile configuration
NAME = bargraph_test
OBJECTS = test.o bargraph.o platform.o
CPU = msp430f149
INCLUDE = ../
VPATH = ../

CFLAGS = -mmcu=${CPU} -O2 -Wall -g -I${INCLUDE}

#switch the compiler (for the internal make rules)
CC = msp430-gcc

CCVER = ${msp430-gcc -dumpversion}

ifeq (,$(findstring 4.4., $(CCVER)))
CPU = msp430x149
else
CPU = msp430f149
endif


.PHONY: all FORCE clean download download-jtag download-bsl dist

#all should be the first target. it's built when make is run without args
Expand Down
59 changes: 21 additions & 38 deletions drivers/bargraph/bargraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,21 @@
#define bitclr(var,bitno) ((var) &= ~(1 << (bitno)))



#define DISP_ON 0x0c //LCD control constants
#define DISP_OFF 0x08 //
#define CLR_DISP 0x01 //
#define CUR_HOME 0x02 //
#define ENTRY_INC 0x06 //
#define DD_RAM_ADDR 0x80 //
#define DD_RAM_ADDR2 0xc0 //
#define DD_RAM_ADDR3 0x28 //
#define CG_RAM_ADDR 0x40 //
// LCD Control Constants
#define DISP_ON 0x0c
#define DISP_OFF 0x08
#define CLR_DISP 0x01
#define CUR_HOME 0x02
#define ENTRY_INC 0x06
#define DD_RAM_ADDR 0x80
#define DD_RAM_ADDR2 0xc0
#define DD_RAM_ADDR3 0x28
#define CG_RAM_ADDR 0x40

// Necessaire a cause d'un bug d'insight
int TMP1,TMP2;
unsigned int val=1;


/*static void delay(unsigned int minor, unsigned int major)
{
int i,j;
for(j=0; j < major; j++)
{
for (i = 0; i<minor; i++)
{
nop();
nop();
}
}
}
*/

void Bargraph_Print(unsigned char segment, unsigned char state)
{
SEL_ON; //LE signal
Expand All @@ -60,57 +45,57 @@ void Bargraph_Print(unsigned char segment, unsigned char state)
switch (segment)
{
case (0):
{ S0_OFF; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_OFF; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_OFF;
S2_OFF;
break;
}
case (1):
{ S0_ON; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_ON; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_OFF;
S2_OFF;
break;
}
case (2):
{ S0_OFF; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_OFF; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_ON;
S2_OFF;
break;
}
case (3):
{ S0_ON; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_ON; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_ON;
S2_OFF;
break;
}
case (4):
{ S0_OFF; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_OFF; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_OFF;
S2_ON;
break;
}
case (5):
{ S0_ON; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_ON; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_OFF;
S2_ON;
break;
}
case (6):
{ S0_OFF; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_OFF; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_ON;
S2_ON;
break;
}
case (7):
{ S0_ON; //line selection 1/8 (msb) S2 S1 S0 (lsb)
{ S0_ON; // Line selection 1/8 (msb) S2 S1 S0 (lsb)
S1_ON;
S2_ON;
break;
}

}
default: break;
}
SEL_OFF; //LATCH

SEL_OFF; // LATCH
SEL_ON;
}

Expand Down Expand Up @@ -148,5 +133,3 @@ void Bargraph_Fall(void)
Bargraph_Print(i,LED_OFF);
}
}


17 changes: 9 additions & 8 deletions drivers/bargraph/bargraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
#define LED_ON 0x01
#define LED_OFF 0x00

/* Light on/off the led represented by segment parameter (8 segments in total).
* Possible values for state are LED_ON and LED_OFF
/*
Light on/off the led represented by segment parameter (8 segments in total).
Possible values for state are LED_ON and LED_OFF
*/
void Bargraph_Print(unsigned char segment, unsigned char state);


/* Light on all the segments one after the other (with 1ms delay between each one).
*
/*
Light on all the segments one after the other (with 1ms delay between each one).
*/
void Bargraph_Rise_On(void);

/* Same as Rise_On, but with only one segment switched on at a time.
*
/*
Same as Rise_On, but with only one segment switched on at a time.
*/
void Bargraph_Rise(void);

/* Same as Rise, but starting from the last segment.
*
/*
Same as Rise, but starting from the last segment.
*/
void Bargraph_Fall(void);

Expand Down
81 changes: 37 additions & 44 deletions drivers/lcd/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
***** *****
***** Name: display.c *****
***** modified version of Andreas Dannenberg *****
***** Includes only display specific code. ***** *****
***** Includes only display specific code. ***** *****
******************************************************************/


Expand All @@ -13,21 +13,20 @@
#define bitset(var,bitno) ((var) |= 1 << (bitno))
#define bitclr(var,bitno) ((var) &= ~(1 << (bitno)))

#define DISP_ON 0x0c //LCD control constants
#define DISP_OFF 0x08 //
#define CLR_DISP 0x01 //
#define CUR_HOME 0x02 //
#define ENTRY_INC 0x06 //
#define DD_RAM_ADDR 0x80 //
#define DD_RAM_ADDR2 0xc0 //
#define DD_RAM_ADDR3 0x28 //
#define CG_RAM_ADDR 0x40 //
// LCD Control Constants
#define DISP_ON 0x0c
#define DISP_OFF 0x08
#define CLR_DISP 0x01
#define CUR_HOME 0x02
#define ENTRY_INC 0x06
#define DD_RAM_ADDR 0x80
#define DD_RAM_ADDR2 0xc0
#define DD_RAM_ADDR3 0x28
#define CG_RAM_ADDR 0x40

// Necessaire a cause d'un bug d'insight
int variableGlobalePourBSS;
int variableGlobalePourDATA=1;


int variableGlobalePourDATA = 1;

void _E(void)
{
Expand All @@ -47,38 +46,37 @@ static char HexDigit(int digitvalue)
static void Send_Cmd (unsigned char e)
{
int temp;
Delayx100us(10); //10ms
temp = e & 0xf0; //get upper nibble
Delayx100us(10); // 10ms
temp = e & 0xf0; // Get upper nibble
LCD_Data &= 0x0f;
LCD_Data |= temp; //send CMD to LCD
bitclr(P2OUT,RS); //set LCD to CMD mode
_E(); //toggle E for LCD
LCD_Data |= temp; // Send CMD to LCD
bitclr(P2OUT,RS); // Set LCD to CMD mode
_E(); // Toggle E for LCD
temp = e & 0x0f;
temp = temp << 4; //get down nibble
temp = temp << 4; // Get down nibble
LCD_Data &= 0x0f;
LCD_Data |= temp;
bitclr(P2OUT,RS); //set LCD to CMD mode
_E(); //toggle E for LCD
bitclr(P2OUT,RS); // Set LCD to CMD mode
_E(); // Toggle E for LCD
}

static void Send_Char (unsigned char d)
{
int temp;
Delayx100us(5); //.5ms
temp = d & 0xf0; //get upper nibble
Delayx100us(5); //.5ms
temp = d & 0xf0; // Get upper nibble
LCD_Data &= 0x0f;
LCD_Data |= temp;
bitset(P2OUT,RS); //set LCD to data mode
_E(); //toggle E for LCD
bitset(P2OUT,RS); // Set LCD to data mode
_E(); // Toggle E for LCD
temp = d & 0x0f;
temp = temp << 4; //get down nibble
temp = temp << 4; // Get down nibble
LCD_Data &= 0x0f;
LCD_Data |= temp;
bitset(P2OUT,RS); //set LCD to data mode
_E(); //toggle E for LCD
bitset(P2OUT,RS); // Set LCD to data mode
_E(); // Toggle E for LCD
}


void LCD_Clear(void)
{
Send_Cmd(CLR_DISP);
Expand All @@ -87,13 +85,11 @@ void LCD_Clear(void)

void LCD_First_Line(void)
{
// Send_Cmd(CLR_DISP);
Send_Cmd(DD_RAM_ADDR);
}

void LCD_Second_Line(void)
{
// Send_Cmd(CLR_DISP);
Send_Cmd(DD_RAM_ADDR2);
}

Expand Down Expand Up @@ -129,7 +125,7 @@ void LCD_Print_Hex(unsigned int number)

void LCD_Print_Decimal(int number)
{
// need to move to long int to account for
// Need to move to long int to account for
// negative 32768
char DecimalBuffer[7];
long lNumber = number;
Expand All @@ -154,20 +150,20 @@ void LCD_Print_Decimal(int number)
void LCD_Init(void)
{
bitclr(P2OUT,RS);
Delayx100us(250); //Delay 100ms
Delayx100us(250); // Delay 100ms
Delayx100us(250);
Delayx100us(250);
Delayx100us(250);
LCD_Data |= BIT4 | BIT5; //D7-D4 = 0011
LCD_Data |= BIT4 | BIT5; // D7-D4 = 0011
LCD_Data &= ~BIT6 & ~BIT7;
_E(); //toggle E for LCD
Delayx100us(100); //10ms
_E(); //toggle E for LCD
Delayx100us(100); //10ms
_E(); //toggle E for LCD
Delayx100us(100); //10ms
_E(); // Toggle E for LCD
Delayx100us(100); // 10ms
_E(); // Toggle E for LCD
Delayx100us(100); // 10ms
_E(); // Toggle E for LCD
Delayx100us(100); // 10ms
LCD_Data &= ~BIT4;
_E(); //toggle E for LCD
_E(); // Toggle E for LCD

Send_Cmd(DISP_ON);
Send_Cmd(CLR_DISP);
Expand All @@ -176,6 +172,3 @@ void LCD_Init(void)
Delayx100us(250);
Delayx100us(250);
}



Loading

0 comments on commit 54a4f04

Please # to comment.