|
From: <ak...@us...> - 2008-02-04 13:17:00
|
Revision: 820
http://can.svn.sourceforge.net/can/?rev=820&view=rev
Author: akhe
Date: 2008-02-04 05:16:58 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
str dev env
Added Paths:
-----------
trunk/firmware/arm/str/common/73x_lcd.c
trunk/firmware/arm/str/common/73x_lcd.h
trunk/firmware/arm/str/common/delay.c
trunk/firmware/arm/str/common/delay.h
trunk/firmware/arm/str/common/eclipse_dev/
trunk/firmware/arm/str/common/flash/
trunk/firmware/arm/str/common/sysTime.c
trunk/firmware/arm/str/common/sysTime.h
Removed Paths:
-------------
trunk/firmware/arm/str/common/str/73x_lcd.c
trunk/firmware/arm/str/common/str/73x_lcd.h
trunk/firmware/arm/str/common/str/Flash/
trunk/firmware/arm/str/common/str/delay.c
trunk/firmware/arm/str/common/str/delay.h
trunk/firmware/arm/str/common/str/str_eclipse_dev/
trunk/firmware/arm/str/common/str/sysTime.c
trunk/firmware/arm/str/common/str/sysTime.h
Copied: trunk/firmware/arm/str/common/73x_lcd.c (from rev 818, trunk/firmware/arm/str/common/str/73x_lcd.c)
===================================================================
--- trunk/firmware/arm/str/common/73x_lcd.c (rev 0)
+++ trunk/firmware/arm/str/common/73x_lcd.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,457 @@
+/******************** (C) COPYRIGHT 2005 STMicroelectronics **********************
+* File Name : 73x_lcd.c
+* Author : MCD Application Team
+* Date First Issued : 09/27/2005 : V1.0
+* Description : This file provides all the LCD software functions.
+**********************************************************************************
+* History:
+* 09/27/2005 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
+* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+/* Standard includes -----------------------------------------------------------*/
+#include "73x_lcd.h"
+#include "73x_lib.h"
+#include "systime.h"
+#include "delay.h"
+/* Include of other module interface headers -----------------------------------*/
+/* Local includes --------------------------------------------------------------*/
+/* Private typedef -------------------------------------------------------------*/
+/* Private define --------------------------------------------------------------*/
+/* Private macro ---------------------------------------------------------------*/
+/* Private variables -----------------------------------------------------------*/
+/* Private function prototypes -------------------------------------------------*/
+// Define GPIO Init Structure */
+GPIO_InitTypeDef GPIO_InitStructure0;
+/* Interface functions ---------------------------------------------------------*/
+/* Private functions -----------------------------------------------------------*/
+
+
+/*******************************************************************************
+* Function Name : LCD_Init
+* Description : Initializes the LCD driver.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_Init(void)
+{
+ /* GPIO6 Clock Enable */
+ CFG_PeripheralClockConfig(CFG_CLK_GPIO6 , ENABLE);
+ /* GPIO6 Configuration */
+ GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
+ GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_0 | GPIO_PIN_1 |GPIO_PIN_10;
+ GPIO_Init(GPIO6, &GPIO_InitStructure0);
+
+ /* GPIO5 Clock Enable */
+ CFG_PeripheralClockConfig(CFG_CLK_GPIO5 , ENABLE);
+ /* GPIO5 Configuration */
+ GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
+ GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_12 | GPIO_PIN_13 |GPIO_PIN_14 |GPIO_PIN_15;
+ GPIO_Init(GPIO5, &GPIO_InitStructure0);
+
+ /* GPIO2 Clock Enable */
+ CFG_PeripheralClockConfig(CFG_CLK_GPIO2 , ENABLE);
+ /* GPIO2 Configuration */
+ GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
+ GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_0;
+ GPIO_Init(GPIO2, &GPIO_InitStructure0);
+ GPIO_BitWrite(GPIO2, GPIO_PIN_0, Bit_SET);
+
+ // Wait 110 ms
+ delay_ms( 110 );
+ LCD_Send_Command_4bit(0x30);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x30);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x30);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x20);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x20);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0xF0);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x00);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x80);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x00);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x10);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x00);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+ LCD_Send_Command_4bit(0x60);
+
+ // Wait 6 ms
+ delay_ms( 6 );
+
+}
+
+/*******************************************************************************
+* Function Name : LCD_E_High
+* Description : Puts the LCD Enable line (E) high.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_E_High(void)
+{
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
+}
+
+/*******************************************************************************
+* Function Name : LCD_E_Low
+* Description : Puts the LCD Enable line (E) low.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_E_Low(void)
+{
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
+}
+
+/*******************************************************************************
+* Function name : LCD_Send_Command_4bit
+* Description : Sends a command to the LCD.
+* Input param : Cmd: command to be sent.
+* Output param : None
+* Return : None
+*******************************************************************************/
+void LCD_Send_Command_4bit(u8 Cmd)
+{
+ // Reset RW bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_RESET);
+
+ // Reset RS bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
+
+ // Set E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
+
+ // Send the command
+ GPIO_ByteWrite(GPIO5, GPIO_MSB, Cmd & 0xF0);
+
+ // Reset E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
+
+ // Cmd Shift
+ Cmd = Cmd << 4;
+
+ // Set E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
+
+ // Send the command
+ GPIO_ByteWrite(GPIO5, GPIO_MSB, Cmd & 0xF0);
+
+ // Reset E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
+
+ // Set RS bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
+
+ // Set RW bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_SET);
+}
+
+/*******************************************************************************
+* Function Name : LCD_SendData_4bit
+* Description : Sends data to the LCD.
+* Input : Data: data to be displayed.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_SendData_4bit(u8 Data)
+{
+
+ // Set RS bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
+
+ // Reset RW bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_RESET);
+
+ // Set E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
+
+ // Data on GPIO_MSB
+ GPIO_ByteWrite(GPIO5, GPIO_MSB, Data & 0xF0);
+
+
+ // Reset E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
+
+ // Data Shift
+ Data = Data << 4;
+
+ // Set E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
+
+ // Data on GPIO_MSB
+ GPIO_ByteWrite(GPIO5, GPIO_MSB, Data);
+
+
+ // Reset E bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
+
+ // Reset RS bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
+
+ // Reset RW bit
+ GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_SET);
+}
+
+/*******************************************************************************
+* Function Name : LCD_SendString
+* Description : Displays a string on the LCD.
+* Input : - pBuffer: pointer to the buffer containing the data to be
+* displayed on the LCD.
+* - Line: specifies the line where the string will be displayed.
+* - Column: specifies the start column from where the string will
+* be displayed.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_SendString(u8 *pBuffer, u8 Line, u8 Column)
+{
+ u8 len = 0, count = 0;
+
+ len = strlen(( const char *)pBuffer);
+
+ if((len < (LCD_HALF_LENGTH + 2 - Column)))
+ {
+ LCD_SetPosCur(Line, Column);
+
+ for(count =0; count < len; count++)
+ {
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+ }
+ else
+ {
+ LCD_SetPosCur(Line, Column);
+
+ for(count = 0; count <= (LCD_HALF_LENGTH-Column); count++)
+ {
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+
+ LCD_SetPosCur(2, 1);
+
+ for(count = (LCD_HALF_LENGTH-Column+1); count < len; count++)
+ {
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+ }
+}
+
+/*******************************************************************************
+* Function Name : LCD_SendStringByStep
+* Description : Displays a string on the LCD by step.
+* Input : - pBuffer: pointer to the buffer containing the data to be
+* displayed on the LCD.
+* - Line: specifies the line where the string will be displayed.
+* - Column: specifies the start column from where the string will
+* be displayed.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_SendStringByStep(u8 *pBuffer, u8 Line, u8 Column)
+{
+ u8 len = 0, count = 0;
+
+ len = strlen(( const char *)pBuffer);
+
+ if(len < (LCD_HALF_LENGTH + 2 - Column))
+ {
+ LCD_SetPosCur(Line, Column);
+
+ for(count =0; count < len; count++)
+ {
+ // wait 200 ms
+ delay_ms( 200 );
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+ }
+ else
+ {
+ LCD_SetPosCur(Line, Column);
+
+ for(count = 0; count <= (LCD_HALF_LENGTH-Column); count++)
+ {
+ // wait 200 ms
+ delay_ms( 200 );
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+
+ LCD_SetPosCur(2, 1);
+
+ for(count = (LCD_HALF_LENGTH-Column+1); count < len; count++)
+ {
+ // wait 200 ms
+ delay_ms( 200 );
+ LCD_SendData_4bit(pBuffer[count]);
+ }
+ }
+}
+
+/*******************************************************************************
+* Function Name : LCD_SendStringPinPong
+* Description : Displays a string on the LCD as ping pong.
+* Input : - pBuffer: pointer to the buffer containing the data to be
+* displayed on the LCD.
+* - Line: specifies the line where the string will be displayed.
+* - nTime: number of ping pong.
+* Output :
+* Return : None
+*******************************************************************************/
+void LCD_SendStringPinPong(u8 *pBuffer, u8 Line, u32 nTime)
+{
+ u8 len = 0, index = 1;
+ bool Direction = TRUE;
+
+ len = strlen(( const char *)pBuffer);
+
+ while(nTime--)
+ {
+ if(Direction)
+ {
+ LCD_SendString(pBuffer, Line, index);
+ // wait 200 ms
+ delay_ms( 200 );
+ index++;
+ LCD_LineClear(Line);
+ if(index == (LCD_HALF_LENGTH - len) + 1)
+ {
+ Direction = FALSE;
+ }
+ }
+ else
+ {
+ LCD_SendString(pBuffer, Line, index);
+ // wait 200 ms
+ delay_ms( 200 );
+ index--;
+ LCD_LineClear(Line);
+ if(index == 1)
+ {
+ Direction = TRUE;
+ }
+ }
+ }
+}
+
+/*******************************************************************************
+* Function Name : LCD_SetPosCur
+* Description : Sets the line and column position of the LCD cursor.
+* Input : - Line: specifies the cursor's line position.
+* - Column: specifies cursor's column position.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_SetPosCur(u8 Line, u8 Column)
+{
+ if(Line == 1)
+ {
+ Column = Column - 1;
+ }
+ else
+ {
+ Column = Column -1 + 64;
+ }
+
+ LCD_Send_Command_4bit(Column | 0x80);
+}
+
+/*******************************************************************************
+* Function Name : LCD_Clear
+* Description : Clears the LCD display.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_Clear(void)
+{
+ /* reset RS bit */
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
+
+ /* send "DISPLAY CLEAR COMMAND" command */
+ LCD_Send_Command_4bit(LCD_CMD_CLR_DISP);
+
+}
+
+/*******************************************************************************
+* Function Name : LCD_LineClear
+* Description : Clears the LCD specified line.
+* Input : Line: line to be cleared.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_LineClear(u8 Line)
+{
+ u8 j = 0;
+
+ /* reset RS bit */
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
+
+ LCD_SetPosCur(Line, 1);
+
+ /* set RS bit */
+ GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
+
+ /* write LCD_HALF_LENGTH spaces to clear the line */
+ for(j = LCD_HALF_LENGTH; j != 0; j--)
+ {
+ LCD_SendData_4bit(' ');
+ }
+}
+
+/*******************************************************************************
+* Function Name : LCD_DigitDisplay
+* Description : Displays a digit on the LCD.
+* Input : - Digit: digit to be displayed.
+* - Line: specifies the line where the digit will be displayed.
+* - Column: specifies the start column from where the digit will
+* be displayed.
+* Output : None
+* Return : None
+*******************************************************************************/
+void LCD_DigitDisplay(u8 Digit, u8 Line, u8 Column)
+{
+ LCD_SetPosCur(Line, Column);
+
+ LCD_SendData_4bit(Digit + 48);
+}
+
+
+
+
+/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE****/
Copied: trunk/firmware/arm/str/common/73x_lcd.h (from rev 818, trunk/firmware/arm/str/common/str/73x_lcd.h)
===================================================================
--- trunk/firmware/arm/str/common/73x_lcd.h (rev 0)
+++ trunk/firmware/arm/str/common/73x_lcd.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,92 @@
+/******************** (C) COPYRIGHT 2005 STMicroelectronics ********************
+* File Name : 73x_lcd.h
+* Author : MCD Application Team
+* Date First Issued : 09/27/2005 : V1.0
+* Description : This file contains all the functions prototypes for the
+* LCD software library.
+**********************************************************************************
+* History:
+* 09/27/2005 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
+* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+/* Define to prevent recursive inclusion ---------------------------------------*/
+#ifndef __73x_LCD_H
+#define __73x_LCD_H
+
+/* Includes ----------------------------------------------------------------- */
+#include "73x_lib.h"
+#include <string.h>
+
+/* Exported types ----------------------------------------------------------- */
+
+#define LCD_LENGTH 32
+#define LCD_HALF_LENGTH (LCD_LENGTH/2)
+
+#define LCD_PORT_COMMAND GPIO6
+#define LCD_PORT_DATA GPIO6
+
+#define LCD_PIN_E GPIO_PIN_0
+#define LCD_PIN_RS GPIO_PIN_1
+#define LCD_PIN_RW GPIO_PIN_10
+
+#define LCD_CMD_4BIT 0x20
+
+#define LCD_CMD_CLR_DISP 0x01
+#define LCD_CMD_CRS_HOME 0x02
+#define LCD_CMD_DECREM_NOSHIFT 0x04
+#define LCD_CMD_DECREM_SHIFT 0x05
+#define LCD_CMD_INCREM_NOSHIFT 0x06
+#define LCD_CMD_INCREM_SHIFT 0x07
+
+#define LCD_CMD_DISPOFF_CURSOFF_BLKOFF 0x08
+#define LCD_CMD_DISPOFF_CURSOFF_BLKON 0x09
+#define LCD_CMD_DISPOFF_CURSON_BLKOFF 0x0A
+#define LCD_CMD_DISPOFF_CURSON_BLKON 0x0B
+#define LCD_CMD_DISPON_CURSOFF_BLKOFF 0x0C
+#define LCD_CMD_DISPON_CURSOFF_BLKON 0x0D
+#define LCD_CMD_DISPON_CURSON_BLKOFF 0x0E
+#define LCD_CMD_DISPON_CURSON_BLKON 0x0F
+
+#define LCD_CMD_CURSMOVE_SHIFTL 0x10
+#define LCD_CMD_CURSMOVE_SHIFTR 0x14
+#define LCD_CMD_DISPSHIFT_SHIFTL 0x18
+#define LCD_CMD_DISPSHIFT_SHIFTR 0x1C
+
+#define LCD_CMD_4BIT_1LINE_8DOT 0x20
+#define LCD_CMD_4BIT_1LINE_10DOT 0x24
+#define LCD_CMD_4BIT_2LINE_8DOT 0x28
+#define LCD_CMD_4BIT_2LINE_10DOT 0x2C
+
+
+/* Module private variables ----------------------------------------------------*/
+
+/* Exported macro --------------------------------------------------------------*/
+
+/* Private functions -----------------------------------------------------------*/
+
+/* Exported functions ----------------------------------------------------------*/
+void LCD_Init(void);
+void LCD_E_High(void);
+void LCD_E_Low(void);
+void LCD_Send_Command_4bit(u8 Cmd);
+void LCD_SendData_4bits(u8 Data);
+void LCD_SendString(u8 *pBuffer, u8 Line, u8 Column);
+void LCD_SendStringByStep(u8 *pBuffer, u8 Line, u8 Column);
+void LCD_SendStringPinPong(u8 *pBuffer, u8 Line, u32 nTime);
+void LCD_SetPosCur(u8 Line, u8 Column);
+void LCD_Clear(void);
+void LCD_LineClear(u8 Line);
+void LCD_DigitDisplay(u8 Digit, u8 Line, u8 Column);
+
+#endif /*__73x_LCD_H */
+
+/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE******/
+
+
Copied: trunk/firmware/arm/str/common/delay.c (from rev 818, trunk/firmware/arm/str/common/str/delay.c)
===================================================================
--- trunk/firmware/arm/str/common/delay.c (rev 0)
+++ trunk/firmware/arm/str/common/delay.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,21 @@
+/*
+ Precise Delay Functions for LPC2100
+ Martin Thomas, 11/2004
+*/
+
+#include "73x_lib.h"
+#include "systime.h"
+#include "delay.h"
+
+
+void delay_us_( u32 delayval )
+{
+ // Not implemented yet
+}
+
+
+void delay_ms( u32 delayval )
+{
+ u32 d = (delayval * 1e-3 * sysTICSperSEC ) + .5;
+ pause( d );
+}
Copied: trunk/firmware/arm/str/common/delay.h (from rev 818, trunk/firmware/arm/str/common/str/delay.h)
===================================================================
--- trunk/firmware/arm/str/common/delay.h (rev 0)
+++ trunk/firmware/arm/str/common/delay.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,14 @@
+
+#ifndef _delay_h_
+#define _delay_h_
+
+#define TUNE_FAC 0.96154
+
+//#include <types.h>
+
+//#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/delayval) /2 ) )
+#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/delayval) /4 * TUNE_FAC) )
+void delay_us_(u32 delayval);
+void delay_ms(u32 delayval);
+
+#endif
Copied: trunk/firmware/arm/str/common/eclipse_dev (from rev 818, trunk/firmware/arm/str/common/str/str_eclipse_dev)
Copied: trunk/firmware/arm/str/common/flash (from rev 818, trunk/firmware/arm/str/common/str/Flash)
Deleted: trunk/firmware/arm/str/common/str/73x_lcd.c
===================================================================
--- trunk/firmware/arm/str/common/str/73x_lcd.c 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/73x_lcd.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,457 +0,0 @@
-/******************** (C) COPYRIGHT 2005 STMicroelectronics **********************
-* File Name : 73x_lcd.c
-* Author : MCD Application Team
-* Date First Issued : 09/27/2005 : V1.0
-* Description : This file provides all the LCD software functions.
-**********************************************************************************
-* History:
-* 09/27/2005 : V1.0
-**********************************************************************************
-* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
-* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
-* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
-* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
-* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*********************************************************************************/
-/* Standard includes -----------------------------------------------------------*/
-#include "73x_lcd.h"
-#include "73x_lib.h"
-#include "systime.h"
-#include "delay.h"
-/* Include of other module interface headers -----------------------------------*/
-/* Local includes --------------------------------------------------------------*/
-/* Private typedef -------------------------------------------------------------*/
-/* Private define --------------------------------------------------------------*/
-/* Private macro ---------------------------------------------------------------*/
-/* Private variables -----------------------------------------------------------*/
-/* Private function prototypes -------------------------------------------------*/
-// Define GPIO Init Structure */
-GPIO_InitTypeDef GPIO_InitStructure0;
-/* Interface functions ---------------------------------------------------------*/
-/* Private functions -----------------------------------------------------------*/
-
-
-/*******************************************************************************
-* Function Name : LCD_Init
-* Description : Initializes the LCD driver.
-* Input : None
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_Init(void)
-{
- /* GPIO6 Clock Enable */
- CFG_PeripheralClockConfig(CFG_CLK_GPIO6 , ENABLE);
- /* GPIO6 Configuration */
- GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
- GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_0 | GPIO_PIN_1 |GPIO_PIN_10;
- GPIO_Init(GPIO6, &GPIO_InitStructure0);
-
- /* GPIO5 Clock Enable */
- CFG_PeripheralClockConfig(CFG_CLK_GPIO5 , ENABLE);
- /* GPIO5 Configuration */
- GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
- GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_12 | GPIO_PIN_13 |GPIO_PIN_14 |GPIO_PIN_15;
- GPIO_Init(GPIO5, &GPIO_InitStructure0);
-
- /* GPIO2 Clock Enable */
- CFG_PeripheralClockConfig(CFG_CLK_GPIO2 , ENABLE);
- /* GPIO2 Configuration */
- GPIO_InitStructure0.GPIO_Mode = GPIO_Mode_OUT_PP;
- GPIO_InitStructure0.GPIO_Pins = GPIO_PIN_0;
- GPIO_Init(GPIO2, &GPIO_InitStructure0);
- GPIO_BitWrite(GPIO2, GPIO_PIN_0, Bit_SET);
-
- // Wait 110 ms
- delay_ms( 110 );
- LCD_Send_Command_4bit(0x30);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x30);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x30);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x20);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x20);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0xF0);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x00);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x80);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x00);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x10);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x00);
-
- // Wait 6 ms
- delay_ms( 6 );
- LCD_Send_Command_4bit(0x60);
-
- // Wait 6 ms
- delay_ms( 6 );
-
-}
-
-/*******************************************************************************
-* Function Name : LCD_E_High
-* Description : Puts the LCD Enable line (E) high.
-* Input : None
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_E_High(void)
-{
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
-}
-
-/*******************************************************************************
-* Function Name : LCD_E_Low
-* Description : Puts the LCD Enable line (E) low.
-* Input : None
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_E_Low(void)
-{
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
-}
-
-/*******************************************************************************
-* Function name : LCD_Send_Command_4bit
-* Description : Sends a command to the LCD.
-* Input param : Cmd: command to be sent.
-* Output param : None
-* Return : None
-*******************************************************************************/
-void LCD_Send_Command_4bit(u8 Cmd)
-{
- // Reset RW bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_RESET);
-
- // Reset RS bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
-
- // Set E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
-
- // Send the command
- GPIO_ByteWrite(GPIO5, GPIO_MSB, Cmd & 0xF0);
-
- // Reset E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
-
- // Cmd Shift
- Cmd = Cmd << 4;
-
- // Set E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
-
- // Send the command
- GPIO_ByteWrite(GPIO5, GPIO_MSB, Cmd & 0xF0);
-
- // Reset E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
-
- // Set RS bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
-
- // Set RW bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_SET);
-}
-
-/*******************************************************************************
-* Function Name : LCD_SendData_4bit
-* Description : Sends data to the LCD.
-* Input : Data: data to be displayed.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_SendData_4bit(u8 Data)
-{
-
- // Set RS bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
-
- // Reset RW bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_RESET);
-
- // Set E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
-
- // Data on GPIO_MSB
- GPIO_ByteWrite(GPIO5, GPIO_MSB, Data & 0xF0);
-
-
- // Reset E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
-
- // Data Shift
- Data = Data << 4;
-
- // Set E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_SET);
-
- // Data on GPIO_MSB
- GPIO_ByteWrite(GPIO5, GPIO_MSB, Data);
-
-
- // Reset E bit
- GPIO_BitWrite(GPIO6, LCD_PIN_E, Bit_RESET);
-
- // Reset RS bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
-
- // Reset RW bit
- GPIO_BitWrite(GPIO6, LCD_PIN_RW, Bit_SET);
-}
-
-/*******************************************************************************
-* Function Name : LCD_SendString
-* Description : Displays a string on the LCD.
-* Input : - pBuffer: pointer to the buffer containing the data to be
-* displayed on the LCD.
-* - Line: specifies the line where the string will be displayed.
-* - Column: specifies the start column from where the string will
-* be displayed.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_SendString(u8 *pBuffer, u8 Line, u8 Column)
-{
- u8 len = 0, count = 0;
-
- len = strlen(( const char *)pBuffer);
-
- if((len < (LCD_HALF_LENGTH + 2 - Column)))
- {
- LCD_SetPosCur(Line, Column);
-
- for(count =0; count < len; count++)
- {
- LCD_SendData_4bit(pBuffer[count]);
- }
- }
- else
- {
- LCD_SetPosCur(Line, Column);
-
- for(count = 0; count <= (LCD_HALF_LENGTH-Column); count++)
- {
- LCD_SendData_4bit(pBuffer[count]);
- }
-
- LCD_SetPosCur(2, 1);
-
- for(count = (LCD_HALF_LENGTH-Column+1); count < len; count++)
- {
- LCD_SendData_4bit(pBuffer[count]);
- }
- }
-}
-
-/*******************************************************************************
-* Function Name : LCD_SendStringByStep
-* Description : Displays a string on the LCD by step.
-* Input : - pBuffer: pointer to the buffer containing the data to be
-* displayed on the LCD.
-* - Line: specifies the line where the string will be displayed.
-* - Column: specifies the start column from where the string will
-* be displayed.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_SendStringByStep(u8 *pBuffer, u8 Line, u8 Column)
-{
- u8 len = 0, count = 0;
-
- len = strlen(( const char *)pBuffer);
-
- if(len < (LCD_HALF_LENGTH + 2 - Column))
- {
- LCD_SetPosCur(Line, Column);
-
- for(count =0; count < len; count++)
- {
- // wait 200 ms
- delay_ms( 200 );
- LCD_SendData_4bit(pBuffer[count]);
- }
- }
- else
- {
- LCD_SetPosCur(Line, Column);
-
- for(count = 0; count <= (LCD_HALF_LENGTH-Column); count++)
- {
- // wait 200 ms
- delay_ms( 200 );
- LCD_SendData_4bit(pBuffer[count]);
- }
-
- LCD_SetPosCur(2, 1);
-
- for(count = (LCD_HALF_LENGTH-Column+1); count < len; count++)
- {
- // wait 200 ms
- delay_ms( 200 );
- LCD_SendData_4bit(pBuffer[count]);
- }
- }
-}
-
-/*******************************************************************************
-* Function Name : LCD_SendStringPinPong
-* Description : Displays a string on the LCD as ping pong.
-* Input : - pBuffer: pointer to the buffer containing the data to be
-* displayed on the LCD.
-* - Line: specifies the line where the string will be displayed.
-* - nTime: number of ping pong.
-* Output :
-* Return : None
-*******************************************************************************/
-void LCD_SendStringPinPong(u8 *pBuffer, u8 Line, u32 nTime)
-{
- u8 len = 0, index = 1;
- bool Direction = TRUE;
-
- len = strlen(( const char *)pBuffer);
-
- while(nTime--)
- {
- if(Direction)
- {
- LCD_SendString(pBuffer, Line, index);
- // wait 200 ms
- delay_ms( 200 );
- index++;
- LCD_LineClear(Line);
- if(index == (LCD_HALF_LENGTH - len) + 1)
- {
- Direction = FALSE;
- }
- }
- else
- {
- LCD_SendString(pBuffer, Line, index);
- // wait 200 ms
- delay_ms( 200 );
- index--;
- LCD_LineClear(Line);
- if(index == 1)
- {
- Direction = TRUE;
- }
- }
- }
-}
-
-/*******************************************************************************
-* Function Name : LCD_SetPosCur
-* Description : Sets the line and column position of the LCD cursor.
-* Input : - Line: specifies the cursor's line position.
-* - Column: specifies cursor's column position.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_SetPosCur(u8 Line, u8 Column)
-{
- if(Line == 1)
- {
- Column = Column - 1;
- }
- else
- {
- Column = Column -1 + 64;
- }
-
- LCD_Send_Command_4bit(Column | 0x80);
-}
-
-/*******************************************************************************
-* Function Name : LCD_Clear
-* Description : Clears the LCD display.
-* Input : None
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_Clear(void)
-{
- /* reset RS bit */
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
-
- /* send "DISPLAY CLEAR COMMAND" command */
- LCD_Send_Command_4bit(LCD_CMD_CLR_DISP);
-
-}
-
-/*******************************************************************************
-* Function Name : LCD_LineClear
-* Description : Clears the LCD specified line.
-* Input : Line: line to be cleared.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_LineClear(u8 Line)
-{
- u8 j = 0;
-
- /* reset RS bit */
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_RESET);
-
- LCD_SetPosCur(Line, 1);
-
- /* set RS bit */
- GPIO_BitWrite(GPIO6, LCD_PIN_RS, Bit_SET);
-
- /* write LCD_HALF_LENGTH spaces to clear the line */
- for(j = LCD_HALF_LENGTH; j != 0; j--)
- {
- LCD_SendData_4bit(' ');
- }
-}
-
-/*******************************************************************************
-* Function Name : LCD_DigitDisplay
-* Description : Displays a digit on the LCD.
-* Input : - Digit: digit to be displayed.
-* - Line: specifies the line where the digit will be displayed.
-* - Column: specifies the start column from where the digit will
-* be displayed.
-* Output : None
-* Return : None
-*******************************************************************************/
-void LCD_DigitDisplay(u8 Digit, u8 Line, u8 Column)
-{
- LCD_SetPosCur(Line, Column);
-
- LCD_SendData_4bit(Digit + 48);
-}
-
-
-
-
-/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE****/
Deleted: trunk/firmware/arm/str/common/str/73x_lcd.h
===================================================================
--- trunk/firmware/arm/str/common/str/73x_lcd.h 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/73x_lcd.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,92 +0,0 @@
-/******************** (C) COPYRIGHT 2005 STMicroelectronics ********************
-* File Name : 73x_lcd.h
-* Author : MCD Application Team
-* Date First Issued : 09/27/2005 : V1.0
-* Description : This file contains all the functions prototypes for the
-* LCD software library.
-**********************************************************************************
-* History:
-* 09/27/2005 : V1.0
-**********************************************************************************
-* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
-* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
-* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
-* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
-* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-*********************************************************************************/
-
-/* Define to prevent recursive inclusion ---------------------------------------*/
-#ifndef __73x_LCD_H
-#define __73x_LCD_H
-
-/* Includes ----------------------------------------------------------------- */
-#include "73x_lib.h"
-#include <string.h>
-
-/* Exported types ----------------------------------------------------------- */
-
-#define LCD_LENGTH 32
-#define LCD_HALF_LENGTH (LCD_LENGTH/2)
-
-#define LCD_PORT_COMMAND GPIO6
-#define LCD_PORT_DATA GPIO6
-
-#define LCD_PIN_E GPIO_PIN_0
-#define LCD_PIN_RS GPIO_PIN_1
-#define LCD_PIN_RW GPIO_PIN_10
-
-#define LCD_CMD_4BIT 0x20
-
-#define LCD_CMD_CLR_DISP 0x01
-#define LCD_CMD_CRS_HOME 0x02
-#define LCD_CMD_DECREM_NOSHIFT 0x04
-#define LCD_CMD_DECREM_SHIFT 0x05
-#define LCD_CMD_INCREM_NOSHIFT 0x06
-#define LCD_CMD_INCREM_SHIFT 0x07
-
-#define LCD_CMD_DISPOFF_CURSOFF_BLKOFF 0x08
-#define LCD_CMD_DISPOFF_CURSOFF_BLKON 0x09
-#define LCD_CMD_DISPOFF_CURSON_BLKOFF 0x0A
-#define LCD_CMD_DISPOFF_CURSON_BLKON 0x0B
-#define LCD_CMD_DISPON_CURSOFF_BLKOFF 0x0C
-#define LCD_CMD_DISPON_CURSOFF_BLKON 0x0D
-#define LCD_CMD_DISPON_CURSON_BLKOFF 0x0E
-#define LCD_CMD_DISPON_CURSON_BLKON 0x0F
-
-#define LCD_CMD_CURSMOVE_SHIFTL 0x10
-#define LCD_CMD_CURSMOVE_SHIFTR 0x14
-#define LCD_CMD_DISPSHIFT_SHIFTL 0x18
-#define LCD_CMD_DISPSHIFT_SHIFTR 0x1C
-
-#define LCD_CMD_4BIT_1LINE_8DOT 0x20
-#define LCD_CMD_4BIT_1LINE_10DOT 0x24
-#define LCD_CMD_4BIT_2LINE_8DOT 0x28
-#define LCD_CMD_4BIT_2LINE_10DOT 0x2C
-
-
-/* Module private variables ----------------------------------------------------*/
-
-/* Exported macro --------------------------------------------------------------*/
-
-/* Private functions -----------------------------------------------------------*/
-
-/* Exported functions ----------------------------------------------------------*/
-void LCD_Init(void);
-void LCD_E_High(void);
-void LCD_E_Low(void);
-void LCD_Send_Command_4bit(u8 Cmd);
-void LCD_SendData_4bits(u8 Data);
-void LCD_SendString(u8 *pBuffer, u8 Line, u8 Column);
-void LCD_SendStringByStep(u8 *pBuffer, u8 Line, u8 Column);
-void LCD_SendStringPinPong(u8 *pBuffer, u8 Line, u32 nTime);
-void LCD_SetPosCur(u8 Line, u8 Column);
-void LCD_Clear(void);
-void LCD_LineClear(u8 Line);
-void LCD_DigitDisplay(u8 Digit, u8 Line, u8 Column);
-
-#endif /*__73x_LCD_H */
-
-/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE******/
-
-
Deleted: trunk/firmware/arm/str/common/str/delay.c
===================================================================
--- trunk/firmware/arm/str/common/str/delay.c 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/delay.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,21 +0,0 @@
-/*
- Precise Delay Functions for LPC2100
- Martin Thomas, 11/2004
-*/
-
-#include "73x_lib.h"
-#include "systime.h"
-#include "delay.h"
-
-
-void delay_us_( u32 delayval )
-{
- // Not implemented yet
-}
-
-
-void delay_ms( u32 delayval )
-{
- u32 d = (delayval * 1e-3 * sysTICSperSEC ) + .5;
- pause( d );
-}
Deleted: trunk/firmware/arm/str/common/str/delay.h
===================================================================
--- trunk/firmware/arm/str/common/str/delay.h 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/delay.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,14 +0,0 @@
-
-#ifndef _delay_h_
-#define _delay_h_
-
-#define TUNE_FAC 0.96154
-
-//#include <types.h>
-
-//#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/delayval) /2 ) )
-#define delay_us(delayval) delay_us_( (uint32_t)( (FOSC*PLL_MUL) / (1000000/delayval) /4 * TUNE_FAC) )
-void delay_us_(u32 delayval);
-void delay_ms(u32 delayval);
-
-#endif
Deleted: trunk/firmware/arm/str/common/str/sysTime.c
===================================================================
--- trunk/firmware/arm/str/common/str/sysTime.c 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/sysTime.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,113 +0,0 @@
-/******************************************************************************
- *
- * $RCSfile: sysTime.c,v $
- * $Revision: 1.4 $
- *
- * This module provides the interface routines for initializing and
- * accessing the system timing functions.
- * Copyright 2004, R O SoftWare
- * No guarantees, warrantees, or promises, implied or otherwise.
- * May be used for hobby or commercial purposes provided copyright
- * notice remains intact.
- *
- *****************************************************************************/
-
-#include "sysTime.h"
-
-vu32 sysTICs;
-
-/******************************************************************************
- *
- * Function Name: initTimebase2()
- *
- * Description:
- * This function initializes the TB2 for use as the system timer.
- *
- * Calling Sequence:
- * void
- *
- * Returns:
- * void
- *
- *****************************************************************************/
-void initTimebase2(void)
-{
- TB_InitTypeDef TB_InitStructure;
-
- sysTICs = 0;
-
- // TB2 Configuration to toggle Leds each 1ms
- CFG_PeripheralClockConfig( CFG_CLK_TB2 , ENABLE );
-
- TB_InitStructure.TB_CLK_Source = TB_CLK_INTERNAL ;
- TB_InitStructure.TB_Prescaler = 50; // The internal TB Frequency = 160KHz
- TB_InitStructure.TB_Preload = 160; // 160000Hz * 0.001 s = 160
-
- TB_Init( TB2, &TB_InitStructure );
- TB_ITConfig( TB2, ENABLE );
- TB_Cmd( TB2, ENABLE );
-}
-
-/******************************************************************************
- *
- * Function Name: getSysTICs()
- *
- * Description:
- * This function returns the current syetem time in TICs.
- *
- * Calling Sequence:
- * void
- *
- * Returns:
- * The current time in TICs as represented by sysTICs
- *
- *****************************************************************************/
-u32 getSysTICs(void)
-{
- return sysTICs;
-}
-
-
-/******************************************************************************
- *
- * Function Name: getElapsedSysTICs()
- *
- * Description:
- * This function then returns the difference in TICs between the
- * given starting time and the current system time.
- *
- * Calling Sequence:
- * The starting time.
- *
- * Returns:
- * The time difference.
- *
- *****************************************************************************/
-u32 getElapsedSysTICs(u32 startTime)
-{
- return getSysTICs() - startTime;
-}
-
-
-/******************************************************************************
- *
- * Function Name: pause()
- *
- * Description:
- * This function does not return until the specified 'duration' in
- * TICs has elapsed.
- *
- * Calling Sequence:
- * duration - length of time in TICs to wait before returning
- *
- * Returns:
- * void
- *
- *****************************************************************************/
-void pause( u32 duration )
-{
- u32 startTime = getSysTICs();
-
- while ( getElapsedSysTICs( startTime ) < duration ) ;
-
-}
Deleted: trunk/firmware/arm/str/common/str/sysTime.h
===================================================================
--- trunk/firmware/arm/str/common/str/sysTime.h 2008-02-04 13:14:12 UTC (rev 819)
+++ trunk/firmware/arm/str/common/str/sysTime.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -1,108 +0,0 @@
-/******************************************************************************
- *
- * $RCSfile: sysTime.h,v $
- * $Revision: 1.2 $
- *
- * This module provides the interface definitions for sysTime.c
- * Copyright 2004, R O SoftWare
- *
- * Ported for STR73xF 2006 <ak...@eu...>
- *
- * No guarantees, warrantees, or promises, implied or otherwise.
- * May be used for hobby or commercial purposes provided copyright
- * notice remains intact.
- *
- *****************************************************************************/
-#ifndef INC_SYS_TIME_H
-#define INC_SYS_TIME_H
-
-#include "73x_lib.h"
-
-// setup parameters
-#define sysTICSperSEC 1000
-
-// some helpful times for pause()
-#define ONE_MS (u32)(( 1e-3 * sysTICSperSEC) + .5)
-#define TWO_MS (u32)(( 2e-3 * sysTICSperSEC) + .5)
-#define FIVE_MS (u32)(( 5e-3 * sysTICSperSEC) + .5)
-#define TEN_MS (u32)(( 10e-3 * sysTICSperSEC) + .5)
-#define TWENTY_MS (u32)(( 20e-3 * sysTICSperSEC) + .5)
-#define THIRTY_MS (u32)(( 30e-3 * sysTICSperSEC) + .5)
-#define FIFTY_MS (u32)(( 50e-3 * sysTICSperSEC) + .5)
-#define HUNDRED_MS (u32)((100e-3 * sysTICSperSEC) + .5)
-#define ONE_FIFTY_MS (u32)((150e-3 * sysTICSperSEC) + .5)
-#define QUARTER_SEC (u32)((250e-3 * sysTICSperSEC) + .5)
-#define HALF_SEC (u32)((500e-3 * sysTICSperSEC) + .5)
-#define ONE_SEC (u32)(( 1.0 * sysTICSperSEC) + .5)
-#define TWO_SEC (u32)(( 2.0 * sysTICSperSEC) + .5)
-#define FIVE_SEC (u32)(( 5.0 * sysTICSperSEC) + .5)
-#define TEN_SEC (u32)((10.0 * sysTICSperSEC) + .5)
-
-
-/******************************************************************************
- *
- * Function Name: initTimebase2()
- *
- * Description:
- * Init. TB2 for 1ms interrupts.
- *
- * Calling Sequence:
- * void
- *
- * Returns:
- * void
- *
- *****************************************************************************/
-void initTimebase2(void);
-
-/******************************************************************************
- *
- * Function Name: getSysTICs()
- *
- * Description:
- * This function returns the current system time in TICs.
- *
- * Calling Sequence:
- * void
- *
- * Returns:
- * The current time in TICs
- *
- *****************************************************************************/
-u32 getSysTICs(void);
-
-/******************************************************************************
- *
- * Function Name: getElapsedSysTICs()
- *
- * Description:
- * This function then returns the difference in TICs between the
- * given starting time and the current system time.
- *
- * Calling Sequence:
- * The starting time.
- *
- * Returns:
- * The time difference.
- *
- *****************************************************************************/
-u32 getElapsedSysTICs( u32 startTime);
-
-/******************************************************************************
- *
- * Function Name: pause()
- *
- * Description:
- * This function does not return until the specified 'duration' in
- * TICs has elapsed.
- *
- * Calling Sequence:
- * duration - length of time in TICs to wait before returning
- *
- * Returns:
- * void
- *
- *****************************************************************************/
-void pause( u32 duration);
-
-#endif
Copied: trunk/firmware/arm/str/common/sysTime.c (from rev 818, trunk/firmware/arm/str/common/str/sysTime.c)
===================================================================
--- trunk/firmware/arm/str/common/sysTime.c (rev 0)
+++ trunk/firmware/arm/str/common/sysTime.c 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ *
+ * $RCSfile: sysTime.c,v $
+ * $Revision: 1.4 $
+ *
+ * This module provides the interface routines for initializing and
+ * accessing the system timing functions.
+ * Copyright 2004, R O SoftWare
+ * No guarantees, warrantees, or promises, implied or otherwise.
+ * May be used for hobby or commercial purposes provided copyright
+ * notice remains intact.
+ *
+ *****************************************************************************/
+
+#include "sysTime.h"
+
+vu32 sysTICs;
+
+/******************************************************************************
+ *
+ * Function Name: initTimebase2()
+ *
+ * Description:
+ * This function initializes the TB2 for use as the system timer.
+ *
+ * Calling Sequence:
+ * void
+ *
+ * Returns:
+ * void
+ *
+ *****************************************************************************/
+void initTimebase2(void)
+{
+ TB_InitTypeDef TB_InitStructure;
+
+ sysTICs = 0;
+
+ // TB2 Configuration to toggle Leds each 1ms
+ CFG_PeripheralClockConfig( CFG_CLK_TB2 , ENABLE );
+
+ TB_InitStructure.TB_CLK_Source = TB_CLK_INTERNAL ;
+ TB_InitStructure.TB_Prescaler = 50; // The internal TB Frequency = 160KHz
+ TB_InitStructure.TB_Preload = 160; // 160000Hz * 0.001 s = 160
+
+ TB_Init( TB2, &TB_InitStructure );
+ TB_ITConfig( TB2, ENABLE );
+ TB_Cmd( TB2, ENABLE );
+}
+
+/******************************************************************************
+ *
+ * Function Name: getSysTICs()
+ *
+ * Description:
+ * This function returns the current syetem time in TICs.
+ *
+ * Calling Sequence:
+ * void
+ *
+ * Returns:
+ * The current time in TICs as represented by sysTICs
+ *
+ *****************************************************************************/
+u32 getSysTICs(void)
+{
+ return sysTICs;
+}
+
+
+/******************************************************************************
+ *
+ * Function Name: getElapsedSysTICs()
+ *
+ * Description:
+ * This function then returns the difference in TICs between the
+ * given starting time and the current system time.
+ *
+ * Calling Sequence:
+ * The starting time.
+ *
+ * Returns:
+ * The time difference.
+ *
+ *****************************************************************************/
+u32 getElapsedSysTICs(u32 startTime)
+{
+ return getSysTICs() - startTime;
+}
+
+
+/******************************************************************************
+ *
+ * Function Name: pause()
+ *
+ * Description:
+ * This function does not return until the specified 'duration' in
+ * TICs has elapsed.
+ *
+ * Calling Sequence:
+ * duration - length of time in TICs to wait before returning
+ *
+ * Returns:
+ * void
+ *
+ *****************************************************************************/
+void pause( u32 duration )
+{
+ u32 startTime = getSysTICs();
+
+ while ( getElapsedSysTICs( startTime ) < duration ) ;
+
+}
Copied: trunk/firmware/arm/str/common/sysTime.h (from rev 818, trunk/firmware/arm/str/common/str/sysTime.h)
===================================================================
--- trunk/firmware/arm/str/common/sysTime.h (rev 0)
+++ trunk/firmware/arm/str/common/sysTime.h 2008-02-04 13:16:58 UTC (rev 820)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ *
+ * $RCSfile: sysTime.h,v $
+ * $Revision: 1.2 $
+ *
+ * This module provides the interface definitions for sysTime.c
+ * Copyright 2004, R O SoftWare
+ *
+ * Ported for STR73xF 2006 <ak...@eu...>
+ *
+ * No guarantees, warrantees, or promises, implied or otherwise.
+ * May be used for hobby or commercial purposes provided copyright
+ * notice remains intact.
+ *
+ *****************************************************************************/
+#ifndef INC_SYS_TIME_H
+#define INC_SYS_TIME_H
+
+#include "73x_lib.h"
+
+// setup parameters
+#define sysTICSperSEC 1000
+
+// some helpful times for pause()
+#define ONE_MS (u32)(( 1e-3 * sysTICSperSEC) + .5)
+#define TWO_MS (u32)(( 2e-3 * sysTICSperSEC) + .5)
+#define FIVE_MS (u32)(( 5e-3 * sysTICSperSEC) + .5)
+#define TEN_MS (u32)(( 10e-3 * sysTICSperSEC) + .5)
+#define TWENTY_MS (u32)(( 20e-3 * sysTICSperSEC) + .5)
+#define THIRTY_MS (u32)(( 30e-3 * sysTICSperSEC) + .5)
+#define FIFTY_MS (u32)(( 50e-3 * sysTICSperSEC) + .5)
+#define HUNDRED_MS (u32)((100e-3 * sysTICSperSEC) + .5)
+#define ONE_FIFTY_MS (u32)((150e-3 * sysTICSperSEC) + .5)
+#define QUARTER_SEC (u32)((250e-3 * sysTICSperSEC) + .5)
+#define HALF_SEC (u32)((500e-3 * sysTICSperSEC) + .5)
+#define ONE_SEC (u32)(( 1.0 * sysTICSperSEC) + .5)
+#define TWO_SEC (u32)(( 2.0 * sysTICSperSEC) + .5)
+#define FIVE_SEC (u32)(( 5.0 * sysTICSperSEC) + .5)
+#define TEN_SEC (u32)((10.0 * sysTICSperSEC) + .5)
+
+
+/******************************************************************************
+ *
+ * Function Name: initTimebase2()
+ *
+ * Description:
+ * Init. TB2 for 1ms interrupts.
+ *
+ * Calling Sequence:
+ * void
+ *
+ * Returns:
+ * void
+ *
+ *****************************************************************************/
+void initTimebase2(void);
+
+/******************************************************************************
+ *
+ * Function Name: getSysTICs()
+ *
+ * Description:
+ * This function returns the current system time in TICs.
+ *
+ * Calling Sequence:
+ * void
+ *
+ * Returns:
+ * The current time in TICs
+ *
+ *****************************************************************************/
+u32 getSysTICs(void);
+
+/******************************************************************************
+ *
+ * Function Name: getElapsedSysTICs()
+ *
+ * Description:
+ * This function then returns the difference in TICs between the
+ * given starting time and the current system time.
+ *
+ * Calling Sequence:
+ * The starting time.
+ *
+ * Returns:
+ * The time difference.
+ *
+ *****************************************************************************/
+u32 getElapsedSysTICs( u32 startTime);
+
+/******************************************************************************
+ *
+ * Function Name: pause()
+ *
+ * Description:
+ * This function does not return until the specified 'duration' in
+ * TICs has elapsed.
+ *
+ * Calling Sequence:
+ * duration - length of time in TICs to wait before returning
+ *
+ * Returns:
+ * void
+ *
+ *****************************************************************************/
+void pause( u32 duration);
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|