Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main.c
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- #define readAddress 0xEF
- #define writeAddress 0xEE
- /* Oversampling setting */
- //volatile uint8_t OSS = 0;
- // Calibration values
- int ac1;
- int ac2;
- int ac3;
- unsigned int ac4;
- unsigned int ac5;
- unsigned int ac6;
- int b1;
- int b2;
- int mb;
- int mc;
- int md;
- /*
- long b5;
- short temperature;
- long pressure;
- // Use these for altitude conversions
- const float p0 = 101325; // Pressure at sea level (Pa)
- float altitude;
- */
- /*
- int BMP085readCalibration(uint8_t address)
- {
- uint8_t msb, lsb;
- msb = TM_I2C_Read(I2C1, writeAddress, address);
- lsb = TM_I2C_Read(I2C1, writeAddress, address + 1);
- return (int) msb << 8 | lsb;
- }
- void BMP085Calibration()
- {
- ac1 = BMP085readCalibration(0xAA);
- ac2 = BMP085readCalibration(0xAC);
- ac3 = BMP085readCalibration(0xAE);
- ac4 = BMP085readCalibration(0xB0);
- ac5 = BMP085readCalibration(0xB2);
- ac6 = BMP085readCalibration(0xB4);
- b1 = BMP085readCalibration(0xB6);
- b2 = BMP085readCalibration(0xB8);
- mb = BMP085readCalibration(0xBA);
- mc = BMP085readCalibration(0xBC);
- md = BMP085readCalibration(0xBE);
- }
- int BMP085readUT()
- {
- int ut,i;
- TM_I2C_Write(I2C1, writeAddress, 0xF4, 0x2E);
- Delayms(5);
- ut = BMP085readCalibration(0xF6);
- return ut;
- }
- */
- int main(void)
- {
- /* System initialization*/
- SystemInit();
- /* Initialize I2C, SCL = PB6 and SDA = PB7 with 100kHz serial clock */
- //TM_I2C_Init(I2C1, TM_I2C_PinsPack_1, 100000);
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
- GPIO_InitTypeDef GPIO_InitDef;
- GPIO_InitDef.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;
- GPIO_InitDef.GPIO_OType = GPIO_OType_PP;
- GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitDef.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz;
- //Initialize pins
- GPIO_Init(GPIOG, &GPIO_InitDef);
- TM_DELAY_Init();
- //BMP085Calibration();
- //int temperature = BMP085readUT();
- while (1)
- {
- GPIO_ToggleBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);
- Delayms(1000);
- }
- }
- //main.h
- /* Define to prevent recursive inclusion -------------------------------------*/
- #ifndef __MAIN_H
- #define __MAIN_H
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f4xx.h"
- #include "tm_stm32f4_delay.h"
- #include "tm_stm32f4_onewire.h"
- #include "tm_stm32f4_usart.h"
- #include "tm_stm32f4_i2c.h"
- #include "tm_stm32f4_timer_properties.h"
- #include <stdio.h>
- /* Exported types ------------------------------------------------------------*/
- /* Exported constants --------------------------------------------------------*/
- /* Exported macro ------------------------------------------------------------*/
- /* Exported functions ------------------------------------------------------- */
- #endif /* __MAIN_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement