/branches/V0.1 killagreg/hw_config.c |
---|
File deleted |
/branches/V0.1 killagreg/91x_conf.h |
---|
41,7 → 41,7 |
/************************* FMI *************************/ |
#define _FMI |
/************************* WIU *************************/ |
//#define _WIU |
#define _WIU |
/************************* TIM *************************/ |
#define _TIM |
#define _TIM0 |
/branches/V0.1 killagreg/GPSUart.c |
---|
182,13 → 182,14 |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
// set port pin 5.0 (serial data to compass) to input |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
// map UART0 to GPS |
// set port pin 6.6 (serial data from gps) to input and connect to IP |
196,13 → 197,14 |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; //UART0_RxD |
GPIO_Init(GPIO6, &GPIO_InitStructure); |
// set port pin 6.7 (serial data to gps) to output |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3; //UART0_TX |
GPIO_Init(GPIO6, &GPIO_InitStructure); |
} |
218,15 → 220,16 |
// set port pin 6.6 (serial data from gps) to input and disconnect from IP |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO6, &GPIO_InitStructure); |
// set port pin 6.7 (serial data to gps) to input |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO6, &GPIO_InitStructure); |
// map UART0 to Compass |
235,13 → 238,14 |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; //UART0_RxD |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
// set port pin 5.0 (serial data to compass) to output |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3; //UART0_TX |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
} |
256,7 → 260,7 |
SCU_APBPeriphClockConfig(__UART0, ENABLE); // Enable the UART0 Clock |
Connect_UART0_to_GPS(); // initialize pins to GPS |
Connect_UART0_to_GPS(); // initialize pins to GPS serial interface |
/* UART1 configured as follow: |
- Word Length = 8 Bits |
299,7 → 303,7 |
} |
/********************************************************/ |
/* UART0 Interrupt Handler */ |
/* Upate GPS data stcructure */ |
/********************************************************/ |
void Update_GPS_Data (void) |
{ |
/branches/V0.1 killagreg/Navi-Ctrl.Uv2 |
---|
58,6 → 58,7 |
File 4,1,<.\libstr91x\src\91x_ssp.c><91x_ssp.c> |
File 4,1,<.\libstr91x\src\91x_i2c.c><91x_i2c.c> |
File 4,1,<.\libstr91x\src\91x_fmi.c><91x_fmi.c> |
File 4,1,<.\libstr91x\src\91x_wiu.c><91x_wiu.c> |
File 6,1,<.\usblibrary\src\usb_regs.c><usb_regs.c> |
File 6,1,<.\usblibrary\src\usb_core.c><usb_core.c> |
File 6,1,<.\usblibrary\src\usb_init.c><usb_init.c> |
/branches/V0.1 killagreg/i2c.c |
---|
93,11 → 93,11 |
SerialPutString("I2C init..."); |
SCU_APBPeriphClockConfig(__I2C1,ENABLE); |
I2C_DeInit(I2C1); |
// configure P2.2->I2C1_CLKOUT and P2.3->I2C1_DOUT |
GPIO_Struct.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; |
GPIO_Struct.GPIO_Type = GPIO_Type_OpenCollector; |
GPIO_Struct.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_Struct.GPIO_Alternate=GPIO_OutputAlt2; |
GPIO_Struct.GPIO_Alternate=GPIO_OutputAlt2; //I2C1_CLKOUT, I2C1_DOUT |
GPIO_Init(GPIO2, &GPIO_Struct); |
I2C_Struct.I2C_GeneralCall = I2C_GeneralCall_Disable; |
/branches/V0.1 killagreg/interrupt.c |
---|
94,7 → 94,7 |
void FIQ_Handler (void) |
{ |
} |
} |
/******************************************************************************* |
* Function Name : Prefetch_Handler |
* Description : This function handles preftetch abort exception. |
303,9 → 303,9 |
* Function Name : EXTIT1_IRQHandler |
* Description : This function handles the EXTIT1 interrupt request |
*******************************************************************************/ |
void EXTIT1_IRQHandler(void) |
/*void EXTIT1_IRQHandler(void) |
{ |
} |
}*/ |
/******************************************************************************* |
* Function Name : EXTIT2_IRQHandler |
* Description : This function handles the EXTIT2 interrupt request |
/branches/V0.1 killagreg/main.c |
---|
65,8 → 65,10 |
#include "i2c.h" |
#include "timer.h" |
#include "spi_slave.h" |
#include "ssc.h" |
#include "sdc.h" |
#include "usb.h" |
#include "sdc.h" |
#include "main.h" |
u32 TimerCompassUpdate; |
104,10 → 106,12 |
SCU_RCLKDivisorConfig(SCU_RCLK_Div1); // set RCLK (Reference Clock) divisor to 1 (full PPL clock) |
SCU_HCLKDivisorConfig(SCU_HCLK_Div1); // set HCLK (AHB bus clock) divisor to 1 (full Reference Clock) |
SCU_PCLKDivisorConfig(SCU_PCLK_Div2); // set PCLK (APB bus clock) divisor to 2 (half Reference Clock) |
//SCU_BRCLKDivisorConfig(SCU_BRCLK_Div2); // set BRCLK to MCLK/2 |
SCU_PLLFactorsConfig(192,25,3); // PLL = 48 MHz, Feedback Divider N=192, Pre-Divider M=25, Post-Divider P=3 |
SCU_PLLCmd(ENABLE); // Enable PLL (is disabled by SCU_PLLFactorsConfig) |
SCU_MCLKSourceConfig(SCU_MCLK_PLL); // set master clock source to PLL |
/* Fill Version Info Structure */ |
VersionInfo.Major = VERSION_MAJOR; |
VersionInfo.Minor = VERSION_MINOR; |
119,6 → 123,8 |
VIC_DeInit(); // deinitializes the VIC module registers to their default reset values. |
// initialize the interrupt handler |
Interrupt_Init(); |
// initialize timer 1 |
TIMER1_Init(); |
// initialize the LEDs |
Led_Init(); |
// initialize the debug UART1 |
132,11 → 138,13 |
USB_ConfigInit(); |
// initialize SPI0 to FC |
SPI0_Init(); |
// initialize timer 1 |
TIMER1_Init(); |
// initialize i2c bus to MK3MAG |
I2C1_Init(); |
// initialise SSC to the sdcard. |
SSC_Init(); |
// try to initialize the sd card |
SDC_Init(); |
// get version from MK3MAG |
I2C_Version.Major = 0xFF; |
SendI2C_Command(I2C_CMD_VERSION); |
146,6 → 154,8 |
TimerCompassUpdate = SetDelay(5); |
TimerI2CReadDelay = SetDelay(5); |
/* |
InitFat16(); |
/branches/V0.1 killagreg/sdc.c |
---|
59,6 → 59,8 |
#include "uart.h" |
#include "sdc.h" |
#include "ssc.h" |
#include "timer.h" |
#include "main.h" |
//________________________________________________________________________________________________________________________________________ |
141,49 → 143,39 |
// September 25, 2006 |
// SD Group |
*/ |
u8 SDC_Init(void) |
{ |
GPIO_InitTypeDef GPIO_InitStructure; |
SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
Result_t SDInitState = SD_ERROR_UNKNOWN; |
/* Configure SD_SWITCH at pin GPIO5.3*/ |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
u16 Timeout = 0; |
Result_t SDC_Init(void) |
{ |
SerialPutString("SD init..."); |
u32 Timeout = 0; |
// initialized to CMD0 (GO_IDLE_STATE) |
u8 CMD[] = {0x40,0x00,0x00,0x00,0x00,0x95}; |
u8 b; |
SSC_Init(); // Initialise SSC to transmit data to the sdcard. |
SerialPutString("Init SD..."); |
// relict from MMC reset! Useless for SD-Cards |
for (b = 0;b<0x0f;b++) |
SDInitState = SD_ERROR_UNKNOWN; |
SSC_Disable(); |
// at least 72 clock cycles with CS dectivated (logic high) to initiate a hardwar reset |
for (Timeout = 0; Timeout < 10; Timeout++) // 10*8 = 80 cycles |
{ |
SSC_PutChar(0xff); |
} |
// Try to enable the SPI-Mode at the sd-card. |
// Send CMD0 (GO_IDLE_STATE) to the sd-card when CS-SD is activated (lowactive!) |
// Send CMD0 (GO_IDLE_STATE) to the sd-card when CS-SD is activated (lowactive) |
// until the response byte indicates no error and in idle state (0x01). |
SerialPutString("SD reset..."); |
while(SDC_PutCommand (CMD) != 0x01) |
{ |
if (Timeout++ > 200) |
{ |
return(1); |
SerialPutString("reset timeout.\r\n"); |
SDInitState = SD_ERROR_RESET; |
return(SDInitState); |
} |
} |
SerialPutString("ok.\r\n"); |
Timeout = 0; |
// Sending CMD1 (SEND_OP_COND) to the sd-card. |
// (Sends host capacity support information and activates the card's initialization process.) |
191,23 → 183,49 |
// only if used after re-initializing a card (not after power on reset). |
CMD[0] = 0x41; // update command index |
CMD[5] = 0xFF; // and CRC7 checksum |
// Send CMD1 until response byte indicated |
SerialPutString("SD initialize..."); |
// Send CMD1 until response byte indicates end of idle state |
Timeout = SetDelay(200); // set timeout to 200 ms (large cards tend to longer) |
while( SDC_PutCommand (CMD) != 0x00) |
{ |
if (Timeout++ > 100) |
if(CheckDelay(Timeout)) |
{ |
return(2); |
SerialPutString("initialize timeout.\r\n"); |
SDInitState = SD_ERROR_RESET; |
return(SDInitState); |
} |
} |
SSC_Disable(); |
SerialPutString("ok.\r\n"); |
SSC_Disable(); // disable sdcard. |
return(0); |
SDInitState = SD_SUCCESS; // disable sdcard. |
return(SDInitState); |
} |
//________________________________________________________________________________________________________________________________________ |
// Funtion: EXTIT1_IRQHandler(void); |
// |
// Description: This function handles the extnernal interrupts from port 5.3 (SD_SWITCH) |
// |
// |
// Returnvalue: none |
//________________________________________________________________________________________________________________________________________ |
void EXTIT1_IRQHandler(void) |
{ |
VIC_ITCmd(EXTIT1_ITLine, DISABLE); |
if(WIU_GetITStatus(WIU_Line11) != RESET) |
{ |
if(SD_SWITCH) // if sd-card is mechanically present |
{ |
BeepTime = 50; |
DebugOut.Analog[4]++; |
SDC_Init(); // initialize sd-card. |
} |
WIU_ClearFlag(WIU_Line1); |
WIU_ClearITPendingBit(WIU_Line11); |
} |
VIC_ITCmd(EXTIT1_ITLine, ENABLE); |
} |
//________________________________________________________________________________________________________________________________________ |
// Funtion: SDC_PutCommand(* CMD); |
// |
/branches/V0.1 killagreg/sdc.h |
---|
9,7 → 9,16 |
// |
//________________________________________________________________________________________________________________________________________ |
extern u8 SDC_Init(void); |
typedef enum |
{ |
SD_SUCCESS, |
SD_ERROR_RESET, |
SD_ERROR_INITIALIZE, |
SD_ERROR_UNKNOWN |
} Result_t; |
extern Result_t SDInitState; |
extern Result_t SDC_Init(void); |
extern u8 SDC_GetSector (u32,u8 *); |
extern u8 SDC_PutSector (u32,u8 *); |
extern u8 SDC_PutCommand (u8 *); |
/branches/V0.1 killagreg/spi_slave.c |
---|
216,12 → 216,12 |
SCU_APBPeriphClockConfig(__SSP0 ,ENABLE); |
GPIO_DeInit(GPIO2); |
//SSP0_CLK, SSP0_MOSI, SSP0_SS pins |
//SSP0_CLK, SSP0_MOSI, SSP0_NSS pins |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; //SSP0_SCLK, SSP0_MOSI, SSP0_NSS |
GPIO_Init (GPIO2, &GPIO_InitStructure); |
// SSP0_MISO pin GPIO2.6 |
229,7 → 229,7 |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2; //SSP0_MISO |
GPIO_Init (GPIO2, &GPIO_InitStructure); |
SSP_DeInit(SSP0); |
/branches/V0.1 killagreg/ssc.c |
---|
55,7 → 55,6 |
// + POSSIBILITY OF SUCH DAMAGE. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#include "91x_lib.h" |
#include "uart.h" |
//________________________________________________________________________________________________________________________________________ |
// Module name: ssc.c |
121,10 → 120,9 |
void SSC_Init(void) |
{ |
SerialPutString("SPI1 init..."); |
GPIO_InitTypeDef GPIO_InitStructure; |
SSP_InitTypeDef SSP_InitStructure; |
GPIO_InitTypeDef GPIO_InitStructure; |
SSP_InitTypeDef SSP_InitStructure; |
WIU_InitTypeDef WIU_InitStructure; |
// enable APB clock for SPI1 |
SCU_APBPeriphClockConfig(__SSP1 ,ENABLE); |
// configure P5.4 -> SD-CS as an output pin |
157,14 → 155,38 |
SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low; |
// Set Baud Rate (Prescaler) |
// bit rate is BRCLK/SSP_ClockPrescaler/(1+SSP_ClockRate)) |
// With MSCLK = 48MHz = BRCLK we get for the SPICLK = 48Mhz / 8 / (1+5) = 1MHz |
// With MSCLK = 48MHz/2 = BRCLK we get for the SPICLK = 24Mhz / 8 / (1+5) = 500 kHz |
SSP_InitStructure.SSP_ClockRate = 5; |
SSP_InitStructure.SSP_ClockPrescaler = 8; |
SSP_Init(SSP1, &SSP_InitStructure); |
SSC_Disable(); |
SSP_Cmd(SSP1, ENABLE); |
// Configure SD_SWITCH at pin GPIO5.3 as an external irq 11 |
// configure the port |
SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
SerialPutString("ok\r\n"); |
// configure the EXT11 interrupt line (P5.3) as an IRQ with the lowest priority |
SCU_APBPeriphClockConfig(__WIU, ENABLE); |
WIU_Cmd(ENABLE ); |
WIU_ClearITPendingBit(WIU_Line11); |
WIU_DeInit(); |
WIU_InitStructure.WIU_TriggerEdge = WIU_FallingEdge; |
WIU_InitStructure.WIU_Line = WIU_Line11; |
WIU_Init(&WIU_InitStructure); |
// The EXTIT1_IRQHandler() is called every time the SD-Switch is activated (falling edge) |
// by inserting an sd-card |
SCU_WakeUpLineConfig(11); |
VIC_Config(EXTIT1_ITLine, VIC_IRQ, 7); |
VIC_ITCmd(EXTIT1_ITLine, ENABLE); |
} |
/branches/V0.1 killagreg/ssc.h |
---|
9,6 → 9,8 |
// |
//________________________________________________________________________________________________________________________________________ |
#define SD_SWITCH !(GPIO_ReadBit(GPIO5, GPIO_Pin_3)) |
extern void SSC_Init(void); |
extern u8 SSC_GetChar (void); |
extern void SSC_PutChar (u8); |
/branches/V0.1 killagreg/uart.c |
---|
154,16 → 154,16 |
GPIO_DeInit(GPIO3); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; // UART1_RxD |
GPIO_Init(GPIO3, &GPIO_InitStructure); |
/*Configure UART1_Tx pin GPIO3.3*/ |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2; // UART1_TX |
GPIO_Init(GPIO3, &GPIO_InitStructure); |
/* UART1 configured as follow: |
/branches/V0.1 killagreg/usb.c |
---|
76,7 → 76,7 |
SCU_APBPeriphClockConfig(__GPIO0 ,ENABLE); |
SCU_APBPeriphReset(__GPIO0,DISABLE); |
// GPIO_DeInit(GPIO0); |
// GPIO_DeInit(P0.1); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |