Skip to content

Commit

Permalink
STM32CubeIDEのサンプルにclang-formatを適用
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeKato committed Sep 19, 2024
1 parent 545b5bd commit 7964d5e
Show file tree
Hide file tree
Showing 10 changed files with 884 additions and 1,372 deletions.
174 changes: 56 additions & 118 deletions STM32CubeIDE_Sample/STEP2/main.c

Large diffs are not rendered by default.

182 changes: 60 additions & 122 deletions STM32CubeIDE_Sample/STEP3/main.c

Large diffs are not rendered by default.

202 changes: 70 additions & 132 deletions STM32CubeIDE_Sample/STEP4/main.c

Large diffs are not rendered by default.

186 changes: 63 additions & 123 deletions STM32CubeIDE_Sample/STEP5/main.c

Large diffs are not rendered by default.

206 changes: 72 additions & 134 deletions STM32CubeIDE_Sample/STEP6/main.c

Large diffs are not rendered by default.

330 changes: 134 additions & 196 deletions STM32CubeIDE_Sample/STEP7/main.c

Large diffs are not rendered by default.

400 changes: 169 additions & 231 deletions STM32CubeIDE_Sample/STEP8/main.c

Large diffs are not rendered by default.

58 changes: 31 additions & 27 deletions STM32CubeIDE_file/BMX055.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,50 @@

//I2C DMA

#include "main.h"
#include "BMX055.h"

#include "main.h"

extern I2C_HandleTypeDef hi2c1;

static uint8_t BMX055_write_buffer[10];
static uint8_t BMX055_read_buffer[10];

void I2C1_Read_NBytes(uint8_t IC_Addr,uint8_t number_Bytes){
HAL_I2C_Master_Receive_DMA(&hi2c1,(IC_Addr<<1),BMX055_read_buffer,number_Bytes);

void I2C1_Read_NBytes(uint8_t IC_Addr, uint8_t number_Bytes)
{
HAL_I2C_Master_Receive_DMA(&hi2c1, (IC_Addr << 1), BMX055_read_buffer, number_Bytes);
}

static void I2C1_Write_NBytes(uint8_t IC_Addr,uint8_t number_Bytes){
HAL_I2C_Master_Transmit_DMA(&hi2c1,(IC_Addr<<1),BMX055_write_buffer,number_Bytes);
static void I2C1_Write_NBytes(uint8_t IC_Addr, uint8_t number_Bytes)
{
HAL_I2C_Master_Transmit_DMA(&hi2c1, (IC_Addr << 1), BMX055_write_buffer, number_Bytes);
}

short I2C1_BMX055_GetGyro16(void){
return (((unsigned short)BMX055_read_buffer[1]<<8)&0xFF00) | BMX055_read_buffer[0];
short I2C1_BMX055_GetGyro16(void)
{
return (((unsigned short)BMX055_read_buffer[1] << 8) & 0xFF00) | BMX055_read_buffer[0];
}

void I2C1_BMX055_zGyro(void){
BMX055_write_buffer[0]=BMX055_GYRO_RATE_Z_LSB;
I2C1_Write_NBytes(BMX055_Addr_Gyro,1);
void I2C1_BMX055_zGyro(void)
{
BMX055_write_buffer[0] = BMX055_GYRO_RATE_Z_LSB;
I2C1_Write_NBytes(BMX055_Addr_Gyro, 1);
}


void I2C1_BMX055_Init(void){
BMX055_write_buffer[0]=BMX055_GYRO_RANGE;//レジスタアドレス
BMX055_write_buffer[1]=0x00;//+/-2000 dps
I2C1_Write_NBytes(BMX055_Addr_Gyro,2);
HAL_Delay(2);

BMX055_write_buffer[0]=BMX055_GYRO_BANDWIDTH;//レジスタアドレス
BMX055_write_buffer[1]=0x01;//ODR 2000Hz
I2C1_Write_NBytes(BMX055_Addr_Gyro,2);
HAL_Delay(2);

BMX055_write_buffer[0]=BMX055_GYRO_LPM1;//レジスタアドレス
BMX055_write_buffer[1]=0x00;//Normal mode,Sleep duration = 2ms
I2C1_Write_NBytes(BMX055_Addr_Gyro,2);
HAL_Delay(2);
void I2C1_BMX055_Init(void)
{
BMX055_write_buffer[0] = BMX055_GYRO_RANGE; //レジスタアドレス
BMX055_write_buffer[1] = 0x00; //+/-2000 dps
I2C1_Write_NBytes(BMX055_Addr_Gyro, 2);
HAL_Delay(2);

BMX055_write_buffer[0] = BMX055_GYRO_BANDWIDTH; //レジスタアドレス
BMX055_write_buffer[1] = 0x01; //ODR 2000Hz
I2C1_Write_NBytes(BMX055_Addr_Gyro, 2);
HAL_Delay(2);

BMX055_write_buffer[0] = BMX055_GYRO_LPM1; //レジスタアドレス
BMX055_write_buffer[1] = 0x00; //Normal mode,Sleep duration = 2ms
I2C1_Write_NBytes(BMX055_Addr_Gyro, 2);
HAL_Delay(2);
}
5 changes: 2 additions & 3 deletions STM32CubeIDE_file/BMX055.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// BMX055 ジャイロセンサのI2Cアドレス
#define BMX055_Addr_Gyro 0x69 // (JP1,JP2,JP3 = Openの時)
// BMX055 磁気センサのI2Cアドレス
#define BMX055_Addr_Mag 0x13 // (JP1,JP2,JP3 = Openの時)
#define BMX055_Addr_Mag 0x13 // (JP1,JP2,JP3 = Openの時)

#define BMX055_GYRO_RANGE 0x0f
#define BMX055_GYRO_BANDWIDTH 0x10
Expand All @@ -26,10 +26,9 @@
#define BMX055_GYRO_RATE_Z_LSB 0x06
#define BMX055_GYRO_RATE_Z_MSB 0x07


void I2C1_BMX055_Init(void);
void I2C1_BMX055_zGyro(void);
void I2C1_Read_NBytes(uint8_t IC_Addr,uint8_t number_Bytes);
void I2C1_Read_NBytes(uint8_t IC_Addr, uint8_t number_Bytes);
short I2C1_BMX055_GetGyro16(void);

#endif /* SRC_BMX055_H_ */
Loading

0 comments on commit 7964d5e

Please sign in to comment.