From 2c3b37404659ff388f02c4121d46f2316ee05ffe Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Fri, 18 Oct 2013 21:16:22 +0000 Subject: [PATCH] Initial commit git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@114 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- test.c | 101 --------------------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 test.c diff --git a/test.c b/test.c deleted file mode 100644 index 6ce1f48..0000000 --- a/test.c +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#define LSM_I2C_Speed 400000 - -//LSM303DLHC geomagnetic module is talking on I2C2 -void initMagneto() -{ - //enable GPIO clocks - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); - RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE); - - // SCL => PB10 - // SDA => PB11 - GPIO_InitTypeDef i2cpinsdef; - i2cpinsdef.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; - i2cpinsdef.GPIO_Speed = GPIO_Speed_50MHz; - i2cpinsdef.GPIO_Mode = GPIO_Mode_AF_OD; - GPIO_Init(GPIOB, &i2cpinsdef); - - // Connect I2C1 pins to AF - GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_I2C1); // SCL - GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_I2C1); // SDA - - I2C_InitTypeDef i2cdef; - i2cdef.I2C_ClockSpeed = LSM_I2C_Speed; - i2cdef.I2C_Mode = I2C_Mode_I2C; - i2cdef.I2C_DutyCycle = I2C_DutyCycle_2; - i2cdef.I2C_OwnAddress1 = 0x00; - i2cdef.I2C_Ack = I2C_Ack_Enable; - i2cdef.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; - I2C_Init(I2Cx, &i2cdef); - I2C_Cmd(I2Cx, ENABLE); -} - -void initLed() -{ - //set Pin22 (PA4) to output mode - GPIO_InitTypeDef pin22def; - pin22def.GPIO_Pin = GPIO_Pin_4; - pin22def.GPIO_Speed = GPIO_Speed_50MHz; - pin22def.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(GPIOA, &pin22def); -} - -void setLed() -{ - GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_SET); -} - -void resetLed() -{ - GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_RESET); -} - -void sleep(int duration) -{ - int i; - for(i = 0 ; i < 1000 * duration ; i++); -} - -static void blinkerTask(void *p) -{ - while (1) - { - setLed(); - vTaskDelay(1357); - resetLed(); - vTaskDelay(1357); - } -} - -int main() -{ - init_malloc_wrapper(); - initLed(); - initMagneto(); - setLed(); - - //start a task - xTaskCreate(blinkerTask, (const char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); - - //start task scheduler - vTaskStartScheduler(); - - return 0; -} - -/* while(1) - { - setLed(); - sleep(1000); - resetLed(); - sleep(1000); - }*/ -- 2.30.2