Compare commits
2 Commits
207f9c9ddf
...
dht11
| Author | SHA1 | Date | |
|---|---|---|---|
| 28b840f1a4 | |||
| 5b4d65d45c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
Debug/*
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +0,0 @@
|
|||||||
#ifndef __EEPROM_24AA02E48
|
|
||||||
#define __EEPROM_24AA02E48
|
|
||||||
|
|
||||||
void EEPROM_24AA02E48_run_test(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#ifndef __CS43L22
|
|
||||||
#define __CS43L22
|
|
||||||
|
|
||||||
void CS43L22_run_test(void);
|
|
||||||
void CS43L22_cleanup(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#ifndef __DNI
|
|
||||||
#define __DNI
|
|
||||||
|
|
||||||
extern ADC_HandleTypeDef hadc1;
|
|
||||||
|
|
||||||
void DNI_show_celsius(void);
|
|
||||||
void DNI_show_fahrenheit(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#ifndef __LIS302DL
|
|
||||||
#define __LIS302DL
|
|
||||||
|
|
||||||
void LIS302DL_run_test(void);
|
|
||||||
void LIS302DL_run_test_dynamic(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#ifndef __PCA9685
|
|
||||||
#define __PCA9685
|
|
||||||
|
|
||||||
void PCA9685_run_test(void);
|
|
||||||
void PCA9685_cleanup(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef __SST25VF016B
|
|
||||||
#define __SST25VF016B
|
|
||||||
|
|
||||||
void SST25VF016B_run_test(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
30
Core/Inc/dht11.h
Normal file
30
Core/Inc/dht11.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef __DHT11
|
||||||
|
#define __DHT11
|
||||||
|
|
||||||
|
#define SKIP_LOW while (!(GPIOD->IDR & 0x0800)) {}
|
||||||
|
#define SKIP_HIGH while (GPIOD->IDR & 0x0800) {}
|
||||||
|
|
||||||
|
#define FILL_REGISTER do { \
|
||||||
|
for (int i = 0; i < 8; i++) { \
|
||||||
|
read_register <<= 1; \
|
||||||
|
SKIP_LOW; \
|
||||||
|
read_register |= dht11_measure_high_duration(); \
|
||||||
|
} } while (0)
|
||||||
|
|
||||||
|
struct SysTickConfig {
|
||||||
|
uint32_t ctrl;
|
||||||
|
uint32_t load;
|
||||||
|
uint32_t val;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DHT11_Data {
|
||||||
|
uint8_t humid_integral;
|
||||||
|
uint8_t humid_decimal;
|
||||||
|
uint8_t temp_integral;
|
||||||
|
uint8_t temp_decimal;
|
||||||
|
uint8_t crc;
|
||||||
|
};
|
||||||
|
|
||||||
|
void dht11_show_both(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
11
Core/Inc/external_temp.h
Normal file
11
Core/Inc/external_temp.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef __EXTERNAL_TEMP
|
||||||
|
#define __EXTERNAL_TEMP
|
||||||
|
|
||||||
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void external_temp_show_celsius(void);
|
||||||
|
void external_temp_show_fahrenheit(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#ifndef __LCD
|
#ifndef __LCD
|
||||||
#define __LCD
|
#define __LCD
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define DISPLAY_RS ((uint16_t) (0x1U << 7))
|
#define DISPLAY_RS ((uint16_t) (0x1U << 7))
|
||||||
#define DISPLAY_RW ((uint16_t) (0x1U << 10))
|
#define DISPLAY_RW ((uint16_t) (0x1U << 10))
|
||||||
#define DISPLAY_ENA ((uint16_t) (0x1U << 11))
|
#define DISPLAY_ENA ((uint16_t) (0x1U << 11))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||||
/* #define HAL_HASH_MODULE_ENABLED */
|
/* #define HAL_HASH_MODULE_ENABLED */
|
||||||
#define HAL_I2C_MODULE_ENABLED
|
/* #define HAL_I2C_MODULE_ENABLED */
|
||||||
/* #define HAL_I2S_MODULE_ENABLED */
|
/* #define HAL_I2S_MODULE_ENABLED */
|
||||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
/* #define HAL_SAI_MODULE_ENABLED */
|
/* #define HAL_SAI_MODULE_ENABLED */
|
||||||
/* #define HAL_SD_MODULE_ENABLED */
|
/* #define HAL_SD_MODULE_ENABLED */
|
||||||
/* #define HAL_MMC_MODULE_ENABLED */
|
/* #define HAL_MMC_MODULE_ENABLED */
|
||||||
#define HAL_SPI_MODULE_ENABLED
|
/* #define HAL_SPI_MODULE_ENABLED */
|
||||||
/* #define HAL_TIM_MODULE_ENABLED */
|
/* #define HAL_TIM_MODULE_ENABLED */
|
||||||
/* #define HAL_UART_MODULE_ENABLED */
|
/* #define HAL_UART_MODULE_ENABLED */
|
||||||
/* #define HAL_USART_MODULE_ENABLED */
|
/* #define HAL_USART_MODULE_ENABLED */
|
||||||
|
|||||||
@@ -55,10 +55,8 @@ void SVC_Handler(void);
|
|||||||
void DebugMon_Handler(void);
|
void DebugMon_Handler(void);
|
||||||
void PendSV_Handler(void);
|
void PendSV_Handler(void);
|
||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
|
||||||
|
|
||||||
void EXTI0_IRQHandler(void);
|
void EXTI0_IRQHandler(void);
|
||||||
void EXTI9_5_IRQHandler(void);
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
/* USER CODE END EFP */
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "24AA02E48.h"
|
|
||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
|
||||||
|
|
||||||
void EEPROM_24AA02E48_run_test(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
|
||||||
|
|
||||||
HAL_StatusTypeDef op_result;
|
|
||||||
size_t err_count = 0;
|
|
||||||
|
|
||||||
// write the Address Pointer register
|
|
||||||
uint8_t data_buffer[13];
|
|
||||||
data_buffer[12] = '\0';
|
|
||||||
data_buffer[0] = 0xF4;
|
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xA0, data_buffer, 1, 2000);
|
|
||||||
|
|
||||||
if (op_result) {
|
|
||||||
err_count++;
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_seq("W ");
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (op_result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
|
||||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 12, 2000);
|
|
||||||
|
|
||||||
if (op_result) {
|
|
||||||
err_count++;
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_seq("R ");
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (op_result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
|
||||||
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq("E ");
|
|
||||||
display_write_data_seq(data_buffer);
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK ");
|
|
||||||
display_write_data_seq(data_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "CS43L22.h"
|
|
||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
|
||||||
|
|
||||||
void CS43L22_run_test(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("CS43L22 Audio");
|
|
||||||
|
|
||||||
HAL_StatusTypeDef op_result;
|
|
||||||
size_t err_count = 0;
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
uint8_t data_buffer[2] = {0x0D, 0x01};
|
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x94, data_buffer, 2, 2000);
|
|
||||||
|
|
||||||
if (op_result) {
|
|
||||||
err_count++;
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("CS43L22 Audio");
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_seq("W ");
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (op_result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("CS43L22 Audio");
|
|
||||||
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq(" Errors");
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CS43L22_cleanup(void)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "LIS302DL.h"
|
|
||||||
|
|
||||||
#define FAILSAFE_PRE_OP for (size_t t = 0; t < 5; t++) {
|
|
||||||
#define FAILSAFE_POST_OP(prefix) if (op_result) print_error_message(op_result, err_count, t, prefix, postfix); else break; }
|
|
||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
|
||||||
|
|
||||||
static char convert_char_at(uint8_t value, size_t position)
|
|
||||||
{
|
|
||||||
char d = (value >> (4 * position)) % 16;
|
|
||||||
|
|
||||||
if (d > 9)
|
|
||||||
d += 7;
|
|
||||||
|
|
||||||
return '0' + d;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_at(uint8_t value, size_t offset)
|
|
||||||
{
|
|
||||||
DISPLAY_SET_CURSOR(1, offset);
|
|
||||||
|
|
||||||
// most significant digit
|
|
||||||
display_write_data_byte(convert_char_at(value, 1));
|
|
||||||
|
|
||||||
// least significant digit
|
|
||||||
display_write_data_byte(convert_char_at(value, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix, char *postfix)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("LIS302DL Accel ");
|
|
||||||
display_write_data_seq(postfix);
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_seq(prefix);
|
|
||||||
display_write_data_byte(' ');
|
|
||||||
|
|
||||||
(*err_count)++;
|
|
||||||
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void retrieve_data(size_t *err_count, uint8_t *data_xyz, char *postfix)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef op_result;
|
|
||||||
uint8_t data_buffer[2];
|
|
||||||
|
|
||||||
// enable device
|
|
||||||
data_buffer[0] = 0x20;
|
|
||||||
data_buffer[1] = 0x47;
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6, data_buffer, 2, 2000);
|
|
||||||
FAILSAFE_POST_OP("E");
|
|
||||||
|
|
||||||
// select OutX register
|
|
||||||
data_buffer[0] = 0x29;
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("SX");
|
|
||||||
|
|
||||||
// receive data from it
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, data_xyz, 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("RX");
|
|
||||||
|
|
||||||
// select OutY register
|
|
||||||
data_buffer[0] = 0x2B;
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("SY");
|
|
||||||
|
|
||||||
// receive data from it
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, &(data_xyz[1]), 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("RY");
|
|
||||||
|
|
||||||
// select OutZ register
|
|
||||||
data_buffer[0] = 0x2D;
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("SZ");
|
|
||||||
|
|
||||||
// receive data from it
|
|
||||||
FAILSAFE_PRE_OP;
|
|
||||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, &(data_xyz[2]), 1, 2000);
|
|
||||||
FAILSAFE_POST_OP("RZ");
|
|
||||||
}
|
|
||||||
|
|
||||||
void LIS302DL_run_test(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("LIS302DL Accel");
|
|
||||||
|
|
||||||
size_t err_count = 0;
|
|
||||||
uint8_t data_xyz[3];
|
|
||||||
|
|
||||||
retrieve_data(&err_count, data_xyz, "");
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("LIS302DL Accel");
|
|
||||||
|
|
||||||
// output retrieved values
|
|
||||||
print_at(data_xyz[2], 14);
|
|
||||||
print_at(data_xyz[1], 11);
|
|
||||||
print_at(data_xyz[0], 8);
|
|
||||||
|
|
||||||
// print the execution stats
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq(" errs");
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LIS302DL_run_test_dynamic(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("LIS302DL Accel D");
|
|
||||||
|
|
||||||
size_t err_count = 0;
|
|
||||||
uint8_t data_xyz[3];
|
|
||||||
|
|
||||||
retrieve_data(&err_count, data_xyz, "D");
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("LIS302DL Accel D");
|
|
||||||
|
|
||||||
// output retrieved values
|
|
||||||
print_at(data_xyz[2], 14);
|
|
||||||
print_at(data_xyz[1], 11);
|
|
||||||
print_at(data_xyz[0], 8);
|
|
||||||
|
|
||||||
// print the execution stats
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq(" errs");
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "PCA9685.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
|
||||||
|
|
||||||
void PCA9685_run_test(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("PCA9685 PWM");
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef op_result;
|
|
||||||
size_t err_count = 0;
|
|
||||||
uint8_t tx_data[10] = {
|
|
||||||
0x00, 0x01,
|
|
||||||
0x06, 0x00,
|
|
||||||
0x07, 0x00,
|
|
||||||
0x08, 0xFF,
|
|
||||||
0x09, 0x0C,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; i += 2) {
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x80, &(tx_data[i]), 2, 2000);
|
|
||||||
|
|
||||||
if (op_result) {
|
|
||||||
err_count++;
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("PCA9685 PWM");
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
|
|
||||||
display_write_data_seq("B");
|
|
||||||
display_write_data_byte('0' + i);
|
|
||||||
display_write_data_byte(':');
|
|
||||||
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (op_result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("PCA9685 PWM");
|
|
||||||
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq(" errors");
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PCA9685_cleanup(void)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
#include "SST25VF016B.h"
|
|
||||||
|
|
||||||
extern SPI_HandleTypeDef hspi1;
|
|
||||||
|
|
||||||
void SST25VF016B_run_test(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("SST25VF016B Flas");
|
|
||||||
|
|
||||||
HAL_StatusTypeDef op_result;
|
|
||||||
size_t err_count = 0;
|
|
||||||
|
|
||||||
uint8_t tx_buffer[8] = {0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
||||||
uint8_t rx_buffer[9];
|
|
||||||
rx_buffer[8] = '\0';
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
|
||||||
HAL_Delay(50);
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
|
||||||
op_result = HAL_SPI_TransmitReceive(&hspi1, tx_buffer, rx_buffer, 8, 2000);
|
|
||||||
|
|
||||||
if (op_result) {
|
|
||||||
err_count++;
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("SST25VF016B Flas");
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
|
||||||
display_write_data_byte('1' + t);
|
|
||||||
display_write_data_seq("/5 ");
|
|
||||||
|
|
||||||
switch (op_result) {
|
|
||||||
case HAL_ERROR:
|
|
||||||
display_write_data_seq("ERROR");
|
|
||||||
break;
|
|
||||||
case HAL_BUSY:
|
|
||||||
display_write_data_seq("BUSY");
|
|
||||||
break;
|
|
||||||
case HAL_TIMEOUT:
|
|
||||||
display_write_data_seq("TIMEOUT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("SST25VF016B Flas");
|
|
||||||
|
|
||||||
if (err_count) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_byte('0' + err_count % 10);
|
|
||||||
display_write_data_seq(" Errors");
|
|
||||||
} else {
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
|
||||||
display_write_data_seq("OK");
|
|
||||||
DISPLAY_SET_CURSOR(1, 8);
|
|
||||||
display_write_data_seq((char) rx_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
101
Core/Src/dht11.c
Normal file
101
Core/Src/dht11.c
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "generic_macros.h"
|
||||||
|
#include "dht11.h"
|
||||||
|
|
||||||
|
static struct SysTickConfig stc;
|
||||||
|
static uint32_t *systick_base = (uint32_t *) SysTick_BASE;
|
||||||
|
|
||||||
|
static void wait(uint32_t wait_us)
|
||||||
|
{
|
||||||
|
int target_time = *(systick_base+8);
|
||||||
|
target_time -= wait_us << 4;
|
||||||
|
|
||||||
|
while (*(systick_base+8) > target_time) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dht11_save_systick_state(void)
|
||||||
|
{
|
||||||
|
stc.ctrl = *(systick_base + 0);
|
||||||
|
stc.load = *(systick_base + 4);
|
||||||
|
stc.val = *(systick_base + 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dht11_load_systick_state(void)
|
||||||
|
{
|
||||||
|
*(systick_base + 4) = stc.load;
|
||||||
|
*(systick_base + 8) = stc.val;
|
||||||
|
*(systick_base + 0) = stc.ctrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dht11_init_systick(void)
|
||||||
|
{
|
||||||
|
dht11_save_systick_state();
|
||||||
|
|
||||||
|
*(systick_base + 0) = 0x5; // disable /8 prescaler, no interrupts, enable counting
|
||||||
|
*(systick_base + 4) = 0xFFFFFF; // load largest possible value
|
||||||
|
|
||||||
|
// verify value load
|
||||||
|
if (*(systick_base + 8) == 0)
|
||||||
|
PANIC(0x4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t dht11_measure_high_duration(void)
|
||||||
|
{
|
||||||
|
int current_time = *(systick_base+8);
|
||||||
|
SKIP_HIGH;
|
||||||
|
|
||||||
|
// elapsed_time > 49us ? 1 : 0
|
||||||
|
return (current_time - *(systick_base+8)) > (49 << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dht11_read_value(struct DHT11_Data *data)
|
||||||
|
{
|
||||||
|
dht11_init_systick();
|
||||||
|
|
||||||
|
register uint8_t read_register = 0;
|
||||||
|
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11; // enable DHT11
|
||||||
|
wait(50000); // hold HIGH for 50 ms
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11 << 16; // start signal
|
||||||
|
wait(30000); // hold it for 30 ms
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11; // pull up, DHT will now take control over the connection
|
||||||
|
|
||||||
|
// switch GPIOD 11 to input mode
|
||||||
|
GPIOD->MODER &= 0xFF3FFFFF;
|
||||||
|
|
||||||
|
// read transmission start sequence from DHT11
|
||||||
|
SKIP_HIGH;
|
||||||
|
SKIP_LOW;
|
||||||
|
SKIP_HIGH;
|
||||||
|
|
||||||
|
// read humidity integral
|
||||||
|
FILL_REGISTER;
|
||||||
|
data->humid_integral = read_register;
|
||||||
|
|
||||||
|
// read humidity decimal
|
||||||
|
FILL_REGISTER;
|
||||||
|
data->humid_decimal = read_register;
|
||||||
|
|
||||||
|
// read temperature integral
|
||||||
|
FILL_REGISTER;
|
||||||
|
data->temp_integral = read_register;
|
||||||
|
|
||||||
|
// read temperature decimal
|
||||||
|
FILL_REGISTER;
|
||||||
|
data->temp_decimal = read_register;
|
||||||
|
|
||||||
|
// read crc
|
||||||
|
FILL_REGISTER;
|
||||||
|
data->crc = read_register;
|
||||||
|
|
||||||
|
// switch GPIOD 11 back to output mode
|
||||||
|
GPIOD->MODER |= 0x00900000;
|
||||||
|
|
||||||
|
dht11_load_systick_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dht11_show_both(void)
|
||||||
|
{
|
||||||
|
struct DHT11_Data data;
|
||||||
|
dht11_read_value(&data);
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "generic_macros.h"
|
#include "generic_macros.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "DNI.h"
|
#include "external_temp.h"
|
||||||
|
|
||||||
static uint32_t DNI_read(void)
|
static uint32_t external_temp_read(void)
|
||||||
{
|
{
|
||||||
HAL_ADC_Start(&hadc1);
|
HAL_ADC_Start(&hadc1);
|
||||||
if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
|
if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
|
||||||
@@ -12,17 +12,17 @@ static uint32_t DNI_read(void)
|
|||||||
return HAL_ADC_GetValue(&hadc1);
|
return HAL_ADC_GetValue(&hadc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DNI_convert_to_celsius(uint32_t value)
|
static int external_temp_convert_to_celsius(uint32_t value)
|
||||||
{
|
{
|
||||||
return (2512 - value) << 2;
|
return (2512 - value) << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DNI_convert_to_fahrenheit(uint32_t value)
|
static int external_temp_convert_to_fahrenheit(uint32_t value)
|
||||||
{
|
{
|
||||||
return (2953 - value) * 50 / 7;
|
return (2953 - value) * 50 / 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DNI_print(int temperature)
|
static void external_temp_print(int temperature)
|
||||||
{
|
{
|
||||||
int add_sign = temperature < 0;
|
int add_sign = temperature < 0;
|
||||||
if (add_sign)
|
if (add_sign)
|
||||||
@@ -55,44 +55,44 @@ static void DNI_print(int temperature)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DNI_print_celsius(int temperature)
|
static void external_temp_print_celsius(int temperature)
|
||||||
{
|
{
|
||||||
DISPLAY_SET_CURSOR(1, 7);
|
DISPLAY_SET_CURSOR(1, 7);
|
||||||
DISPLAY_SET_DECREMENT;
|
DISPLAY_SET_DECREMENT;
|
||||||
display_write_data_seq("C ");
|
display_write_data_seq("C ");
|
||||||
|
|
||||||
DNI_print(temperature);
|
external_temp_print(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DNI_print_fahrenheit(int temperature)
|
static void external_temp_print_fahrenheit(int temperature)
|
||||||
{
|
{
|
||||||
DISPLAY_SET_CURSOR(1, 7);
|
DISPLAY_SET_CURSOR(1, 7);
|
||||||
DISPLAY_SET_DECREMENT;
|
DISPLAY_SET_DECREMENT;
|
||||||
display_write_data_seq("F ");
|
display_write_data_seq("F ");
|
||||||
|
|
||||||
DNI_print(temperature);
|
external_temp_print(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNI_show_celsius(void)
|
void external_temp_show_celsius(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
DISPLAY_SET_INCREMENT;
|
DISPLAY_SET_INCREMENT;
|
||||||
|
|
||||||
display_write_data_seq("DNI Temperature");
|
display_write_data_seq("Temperature");
|
||||||
|
|
||||||
uint32_t value = DNI_read();
|
uint32_t value = external_temp_read();
|
||||||
int temp = DNI_convert_to_celsius(value);
|
int temp = external_temp_convert_to_celsius(value);
|
||||||
DNI_print_celsius(temp);
|
external_temp_print_celsius(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNI_show_fahrenheit(void)
|
void external_temp_show_fahrenheit(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
DISPLAY_SET_INCREMENT;
|
DISPLAY_SET_INCREMENT;
|
||||||
|
|
||||||
display_write_data_seq("DNI Temperature");
|
display_write_data_seq("Temperature");
|
||||||
|
|
||||||
uint32_t value = DNI_read();
|
uint32_t value = external_temp_read();
|
||||||
int temp = DNI_convert_to_fahrenheit(value);
|
int temp = external_temp_convert_to_fahrenheit(value);
|
||||||
DNI_print_fahrenheit(temp);
|
external_temp_print_fahrenheit(temp);
|
||||||
}
|
}
|
||||||
313
Core/Src/main.c
313
Core/Src/main.c
@@ -24,12 +24,8 @@
|
|||||||
|
|
||||||
#include "generic_macros.h"
|
#include "generic_macros.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "DNI.h"
|
#include "external_temp.h"
|
||||||
#include "PCA9685.h"
|
#include "dht11.h"
|
||||||
#include "24AA02E48.h"
|
|
||||||
#include "CS43L22.h"
|
|
||||||
#include "SST25VF016B.h"
|
|
||||||
#include "LIS302DL.h"
|
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
@@ -41,9 +37,6 @@
|
|||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
#define WAIT_UNTIL_CB_PRESSED while (!HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) && HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
|
||||||
#define WAIT_UNTIL_CB_RELEASED while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) || !HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
|
||||||
|
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@@ -54,39 +47,15 @@
|
|||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
ADC_HandleTypeDef hadc1;
|
ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
|
||||||
|
|
||||||
SPI_HandleTypeDef hspi1;
|
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
void ((*executors[])(void)) = {
|
void ((*executors[])(void)) = {
|
||||||
DNI_show_celsius,
|
dht11_show_both,
|
||||||
DNI_show_fahrenheit,
|
external_temp_show_celsius,
|
||||||
PCA9685_run_test,
|
external_temp_show_fahrenheit
|
||||||
EEPROM_24AA02E48_run_test,
|
|
||||||
CS43L22_run_test,
|
|
||||||
SST25VF016B_run_test,
|
|
||||||
LIS302DL_run_test,
|
|
||||||
LIS302DL_run_test_dynamic
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ((*cleanup_functions[])(void)) = {
|
int current_executor_id = 0;
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
PCA9685_cleanup,
|
|
||||||
NULL,
|
|
||||||
CS43L22_cleanup,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
int delay_between_runs[] = {250, 250, -1, -1, -1, -1, -1, 200};
|
|
||||||
|
|
||||||
size_t current_executor_id = 0;
|
|
||||||
|
|
||||||
size_t buttons_interrupt_enabled;
|
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
@@ -94,8 +63,6 @@ size_t buttons_interrupt_enabled;
|
|||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
static void MX_ADC1_Init(void);
|
static void MX_ADC1_Init(void);
|
||||||
static void MX_I2C1_Init(void);
|
|
||||||
static void MX_SPI1_Init(void);
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
@@ -103,132 +70,6 @@ static void MX_SPI1_Init(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
void switch_to_next_test(void)
|
|
||||||
{
|
|
||||||
current_executor_id += 1;
|
|
||||||
current_executor_id %= 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttons_switch_to_interrupt(void)
|
|
||||||
{
|
|
||||||
// save current executor ID
|
|
||||||
size_t tmp = current_executor_id;
|
|
||||||
|
|
||||||
// configure user button
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
|
||||||
|
|
||||||
// configure SW5 (alternative advancing method)
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
|
|
||||||
|
|
||||||
// restore current executor ID
|
|
||||||
current_executor_id = tmp;
|
|
||||||
|
|
||||||
// set interrupt mode flag
|
|
||||||
buttons_interrupt_enabled = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttons_switch_to_input(void)
|
|
||||||
{
|
|
||||||
// configure user button
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
HAL_NVIC_DisableIRQ(EXTI0_IRQn);
|
|
||||||
|
|
||||||
// configure SW5 (alternative input method)
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
|
|
||||||
|
|
||||||
// clear interrupt mode flag
|
|
||||||
buttons_interrupt_enabled = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void button_init_and_test(void)
|
|
||||||
{
|
|
||||||
// letting the buttons be tested
|
|
||||||
display_write_data_seq("Fill any bar:");
|
|
||||||
DISPLAY_SET_CURSOR(1, 5);
|
|
||||||
display_write_data_seq("[-] [-----]");
|
|
||||||
|
|
||||||
size_t pressed_elements;
|
|
||||||
|
|
||||||
uint32_t sw_button_locations[5][2] = {
|
|
||||||
{GPIOC, GPIO_PIN_11},
|
|
||||||
{GPIOA, GPIO_PIN_15},
|
|
||||||
{GPIOC, GPIO_PIN_9},
|
|
||||||
{GPIOC, GPIO_PIN_6},
|
|
||||||
{GPIOC, GPIO_PIN_8}
|
|
||||||
};
|
|
||||||
|
|
||||||
do {
|
|
||||||
HAL_Delay(100);
|
|
||||||
pressed_elements = 0;
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 6);
|
|
||||||
|
|
||||||
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)) {
|
|
||||||
pressed_elements |= 0x20;
|
|
||||||
display_write_data_byte('*');
|
|
||||||
} else {
|
|
||||||
display_write_data_byte('-');
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 10);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 5; i++) {
|
|
||||||
pressed_elements >>= 1;
|
|
||||||
|
|
||||||
size_t input = !HAL_GPIO_ReadPin(sw_button_locations[i][0], sw_button_locations[i][1]);
|
|
||||||
|
|
||||||
if (input) {
|
|
||||||
pressed_elements |= 0x20;
|
|
||||||
display_write_data_byte('*');
|
|
||||||
} else {
|
|
||||||
display_write_data_byte('-');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (!(((pressed_elements & 0x1) == 0x1) || ((pressed_elements & 0x3E) == 0x3E)));
|
|
||||||
|
|
||||||
|
|
||||||
// visual reaction to bar fill
|
|
||||||
DISPLAY_SET_CURSOR(0, 0);
|
|
||||||
display_write_data_seq("Release buttons");
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
|
||||||
HAL_Delay(500);
|
|
||||||
GPIOD->ODR = 0x2000;
|
|
||||||
HAL_Delay(500);
|
|
||||||
GPIOD->ODR = 0x4000;
|
|
||||||
HAL_Delay(500);
|
|
||||||
GPIOD->ODR = 0x8000;
|
|
||||||
HAL_Delay(500);
|
|
||||||
|
|
||||||
// waiting for control buttons to be released
|
|
||||||
WAIT_UNTIL_CB_RELEASED;
|
|
||||||
GPIOD->ODR = 0x0000;
|
|
||||||
HAL_Delay(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,16 +102,12 @@ int main(void)
|
|||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_ADC1_Init();
|
MX_ADC1_Init();
|
||||||
MX_I2C1_Init();
|
|
||||||
MX_SPI1_Init();
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
buttons_interrupt_enabled = 0;
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
|
||||||
display_init();
|
|
||||||
|
|
||||||
GPIOD->ODR = 0xF000;
|
GPIOD->ODR = 0xF000;
|
||||||
button_init_and_test();
|
display_init();
|
||||||
|
HAL_Delay(1000);
|
||||||
|
GPIOD->ODR = 0x0000;
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
@@ -278,29 +115,8 @@ int main(void)
|
|||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (delay_between_runs[current_executor_id] == -1 && buttons_interrupt_enabled)
|
|
||||||
buttons_switch_to_input();
|
|
||||||
else if (delay_between_runs[current_executor_id] != -1 && !buttons_interrupt_enabled)
|
|
||||||
buttons_switch_to_interrupt();
|
|
||||||
|
|
||||||
executors[current_executor_id]();
|
executors[current_executor_id]();
|
||||||
|
HAL_Delay(250);
|
||||||
if (delay_between_runs[current_executor_id] == -1) {
|
|
||||||
WAIT_UNTIL_CB_PRESSED;
|
|
||||||
HAL_Delay(150);
|
|
||||||
GPIOD->BSRR = 0x1000;
|
|
||||||
|
|
||||||
WAIT_UNTIL_CB_RELEASED;
|
|
||||||
HAL_Delay(150);
|
|
||||||
GPIOD->BSRR = 0x1000 << 16;
|
|
||||||
|
|
||||||
if (cleanup_functions[current_executor_id])
|
|
||||||
cleanup_functions[current_executor_id]();
|
|
||||||
|
|
||||||
switch_to_next_test();
|
|
||||||
} else {
|
|
||||||
HAL_Delay(delay_between_runs[current_executor_id]);
|
|
||||||
}
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
@@ -401,78 +217,6 @@ static void MX_ADC1_Init(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief I2C1 Initialization Function
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
static void MX_I2C1_Init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* USER CODE BEGIN I2C1_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN I2C1_Init 1 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_Init 1 */
|
|
||||||
hi2c1.Instance = I2C1;
|
|
||||||
hi2c1.Init.ClockSpeed = 100000;
|
|
||||||
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
|
||||||
hi2c1.Init.OwnAddress1 = 0;
|
|
||||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
|
||||||
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
|
||||||
hi2c1.Init.OwnAddress2 = 0;
|
|
||||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
|
||||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
|
||||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
/* USER CODE BEGIN I2C1_Init 2 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_Init 2 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SPI1 Initialization Function
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
static void MX_SPI1_Init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI1_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI1_Init 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_Init 1 */
|
|
||||||
/* SPI1 parameter configuration*/
|
|
||||||
hspi1.Instance = SPI1;
|
|
||||||
hspi1.Init.Mode = SPI_MODE_MASTER;
|
|
||||||
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
|
||||||
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
|
||||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
|
||||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
|
||||||
hspi1.Init.NSS = SPI_NSS_SOFT;
|
|
||||||
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
|
|
||||||
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
|
||||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
|
||||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
|
||||||
hspi1.Init.CRCPolynomial = 10;
|
|
||||||
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
/* USER CODE BEGIN SPI1_Init 2 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_Init 2 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GPIO Initialization Function
|
* @brief GPIO Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
@@ -489,22 +233,18 @@ static void MX_GPIO_Init(void)
|
|||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
|
||||||
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||||
|GPIO_PIN_4|GPIO_PIN_7, GPIO_PIN_RESET);
|
|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin : PA0 */
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
|
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||||
/*Configure GPIO pins : PA0 PA15 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_15;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
@@ -517,27 +257,18 @@ static void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PD12 PD13 PD14 PD15
|
/*Configure GPIO pins : PD11 PD12 PD13 PD14
|
||||||
PD4 PD7 */
|
PD15 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||||
|GPIO_PIN_4|GPIO_PIN_7;
|
|GPIO_PIN_15;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PC6 PC8 PC9 PC11 */
|
/* EXTI interrupt init*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11;
|
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/*Configure GPIO pin : PB7 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||||
/* USER CODE END MX_GPIO_Init_2 */
|
/* USER CODE END MX_GPIO_Init_2 */
|
||||||
|
|||||||
@@ -140,152 +140,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief I2C MSP Initialization
|
|
||||||
* This function configures the hardware resources used in this example
|
|
||||||
* @param hi2c: I2C handle pointer
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
if(hi2c->Instance==I2C1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN I2C1_MspInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_MspInit 0 */
|
|
||||||
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
/**I2C1 GPIO Configuration
|
|
||||||
PB6 ------> I2C1_SCL
|
|
||||||
PB9 ------> I2C1_SDA
|
|
||||||
*/
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* Peripheral clock enable */
|
|
||||||
__HAL_RCC_I2C1_CLK_ENABLE();
|
|
||||||
/* USER CODE BEGIN I2C1_MspInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_MspInit 1 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief I2C MSP De-Initialization
|
|
||||||
* This function freeze the hardware resources used in this example
|
|
||||||
* @param hi2c: I2C handle pointer
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
|
||||||
{
|
|
||||||
if(hi2c->Instance==I2C1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN I2C1_MspDeInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_MspDeInit 0 */
|
|
||||||
/* Peripheral clock disable */
|
|
||||||
__HAL_RCC_I2C1_CLK_DISABLE();
|
|
||||||
|
|
||||||
/**I2C1 GPIO Configuration
|
|
||||||
PB6 ------> I2C1_SCL
|
|
||||||
PB9 ------> I2C1_SDA
|
|
||||||
*/
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
|
|
||||||
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END I2C1_MspDeInit 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SPI MSP Initialization
|
|
||||||
* This function configures the hardware resources used in this example
|
|
||||||
* @param hspi: SPI handle pointer
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
if(hspi->Instance==SPI1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN SPI1_MspInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspInit 0 */
|
|
||||||
/* Peripheral clock enable */
|
|
||||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
|
||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
/**SPI1 GPIO Configuration
|
|
||||||
PA5 ------> SPI1_SCK
|
|
||||||
PB4 ------> SPI1_MISO
|
|
||||||
PB5 ------> SPI1_MOSI
|
|
||||||
*/
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_5;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI1_MspInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspInit 1 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SPI MSP De-Initialization
|
|
||||||
* This function freeze the hardware resources used in this example
|
|
||||||
* @param hspi: SPI handle pointer
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
|
||||||
{
|
|
||||||
if(hspi->Instance==SPI1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN SPI1_MspDeInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspDeInit 0 */
|
|
||||||
/* Peripheral clock disable */
|
|
||||||
__HAL_RCC_SPI1_CLK_DISABLE();
|
|
||||||
|
|
||||||
/**SPI1 GPIO Configuration
|
|
||||||
PA5 ------> SPI1_SCK
|
|
||||||
PB4 ------> SPI1_MISO
|
|
||||||
PB5 ------> SPI1_MOSI
|
|
||||||
*/
|
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
|
|
||||||
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4|GPIO_PIN_5);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspDeInit 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|||||||
@@ -41,12 +41,14 @@
|
|||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
extern size_t current_executor_id;
|
extern void ((*executors[])(void));
|
||||||
|
extern void *current_executor(void);
|
||||||
|
extern int current_executor_id;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
void switch_to_next_test(void);
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
@@ -198,32 +200,29 @@ void SysTick_Handler(void)
|
|||||||
/* please refer to the startup file (startup_stm32f4xx.s). */
|
/* please refer to the startup file (startup_stm32f4xx.s). */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/**
|
||||||
|
* @brief This function handles EXTI line0 interrupt.
|
||||||
|
*/
|
||||||
void EXTI0_IRQHandler(void)
|
void EXTI0_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
/* USER CODE BEGIN EXTI0_IRQn 0 */
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
GPIOD->ODR = 0x1000;
|
||||||
|
|
||||||
switch_to_next_test();
|
current_executor_id += 1;
|
||||||
|
current_executor_id &= 1;
|
||||||
|
|
||||||
for (int i = 300000; i > 0; i--) asm("nop");
|
for (int i = 900000; i > 0; i--) asm("nop");
|
||||||
|
|
||||||
GPIOD->ODR = 0x0000;
|
GPIOD->ODR = 0x0000;
|
||||||
|
|
||||||
|
/* USER CODE END EXTI0_IRQn 0 */
|
||||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
|
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
|
||||||
|
/* USER CODE BEGIN EXTI0_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END EXTI0_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXTI9_5_IRQHandler(void)
|
/* USER CODE BEGIN 1 */
|
||||||
{
|
|
||||||
GPIOD->ODR = 0x1000;
|
|
||||||
|
|
||||||
switch_to_next_test();
|
|
||||||
|
|
||||||
for (int i = 300000; i > 0; i--) asm("nop");
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x0000;
|
|
||||||
|
|
||||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|||||||
@@ -5,12 +5,9 @@
|
|||||||
|
|
||||||
# Add inputs and outputs from these tool invocations to the build variables
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
C_SRCS += \
|
C_SRCS += \
|
||||||
../Core/Src/24AA02E48.c \
|
../Core/Src/dht11.c \
|
||||||
../Core/Src/CS43L22.c \
|
../Core/Src/external-temperature.c \
|
||||||
../Core/Src/DNI.c \
|
../Core/Src/external_temp.c \
|
||||||
../Core/Src/LIS302DL.c \
|
|
||||||
../Core/Src/PCA9685.c \
|
|
||||||
../Core/Src/SST25VF016B.c \
|
|
||||||
../Core/Src/lcd.c \
|
../Core/Src/lcd.c \
|
||||||
../Core/Src/main.c \
|
../Core/Src/main.c \
|
||||||
../Core/Src/stm32f4xx_hal_msp.c \
|
../Core/Src/stm32f4xx_hal_msp.c \
|
||||||
@@ -20,12 +17,9 @@ C_SRCS += \
|
|||||||
../Core/Src/system_stm32f4xx.c
|
../Core/Src/system_stm32f4xx.c
|
||||||
|
|
||||||
OBJS += \
|
OBJS += \
|
||||||
./Core/Src/24AA02E48.o \
|
./Core/Src/dht11.o \
|
||||||
./Core/Src/CS43L22.o \
|
./Core/Src/external-temperature.o \
|
||||||
./Core/Src/DNI.o \
|
./Core/Src/external_temp.o \
|
||||||
./Core/Src/LIS302DL.o \
|
|
||||||
./Core/Src/PCA9685.o \
|
|
||||||
./Core/Src/SST25VF016B.o \
|
|
||||||
./Core/Src/lcd.o \
|
./Core/Src/lcd.o \
|
||||||
./Core/Src/main.o \
|
./Core/Src/main.o \
|
||||||
./Core/Src/stm32f4xx_hal_msp.o \
|
./Core/Src/stm32f4xx_hal_msp.o \
|
||||||
@@ -35,12 +29,9 @@ OBJS += \
|
|||||||
./Core/Src/system_stm32f4xx.o
|
./Core/Src/system_stm32f4xx.o
|
||||||
|
|
||||||
C_DEPS += \
|
C_DEPS += \
|
||||||
./Core/Src/24AA02E48.d \
|
./Core/Src/dht11.d \
|
||||||
./Core/Src/CS43L22.d \
|
./Core/Src/external-temperature.d \
|
||||||
./Core/Src/DNI.d \
|
./Core/Src/external_temp.d \
|
||||||
./Core/Src/LIS302DL.d \
|
|
||||||
./Core/Src/PCA9685.d \
|
|
||||||
./Core/Src/SST25VF016B.d \
|
|
||||||
./Core/Src/lcd.d \
|
./Core/Src/lcd.d \
|
||||||
./Core/Src/main.d \
|
./Core/Src/main.d \
|
||||||
./Core/Src/stm32f4xx_hal_msp.d \
|
./Core/Src/stm32f4xx_hal_msp.d \
|
||||||
@@ -57,7 +48,7 @@ Core/Src/%.o Core/Src/%.su Core/Src/%.cyclo: ../Core/Src/%.c Core/Src/subdir.mk
|
|||||||
clean: clean-Core-2f-Src
|
clean: clean-Core-2f-Src
|
||||||
|
|
||||||
clean-Core-2f-Src:
|
clean-Core-2f-Src:
|
||||||
-$(RM) ./Core/Src/24AA02E48.cyclo ./Core/Src/24AA02E48.d ./Core/Src/24AA02E48.o ./Core/Src/24AA02E48.su ./Core/Src/CS43L22.cyclo ./Core/Src/CS43L22.d ./Core/Src/CS43L22.o ./Core/Src/CS43L22.su ./Core/Src/DNI.cyclo ./Core/Src/DNI.d ./Core/Src/DNI.o ./Core/Src/DNI.su ./Core/Src/LIS302DL.cyclo ./Core/Src/LIS302DL.d ./Core/Src/LIS302DL.o ./Core/Src/LIS302DL.su ./Core/Src/PCA9685.cyclo ./Core/Src/PCA9685.d ./Core/Src/PCA9685.o ./Core/Src/PCA9685.su ./Core/Src/SST25VF016B.cyclo ./Core/Src/SST25VF016B.d ./Core/Src/SST25VF016B.o ./Core/Src/SST25VF016B.su ./Core/Src/lcd.cyclo ./Core/Src/lcd.d ./Core/Src/lcd.o ./Core/Src/lcd.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
|
-$(RM) ./Core/Src/dht11.cyclo ./Core/Src/dht11.d ./Core/Src/dht11.o ./Core/Src/dht11.su ./Core/Src/external-temperature.cyclo ./Core/Src/external-temperature.d ./Core/Src/external-temperature.o ./Core/Src/external-temperature.su ./Core/Src/external_temp.cyclo ./Core/Src/external_temp.d ./Core/Src/external_temp.o ./Core/Src/external_temp.su ./Core/Src/lcd.cyclo ./Core/Src/lcd.d ./Core/Src/lcd.o ./Core/Src/lcd.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
|
||||||
|
|
||||||
.PHONY: clean-Core-2f-Src
|
.PHONY: clean-Core-2f-Src
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ C_SRCS += \
|
|||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
|
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \
|
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \
|
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
|
||||||
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c
|
../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c
|
||||||
@@ -39,13 +36,10 @@ OBJS += \
|
|||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.o \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.o \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o
|
||||||
@@ -62,13 +56,10 @@ C_DEPS += \
|
|||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.d \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.d \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.d \
|
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.d \
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.d \
|
||||||
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.d
|
./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.d
|
||||||
@@ -81,7 +72,7 @@ Drivers/STM32F4xx_HAL_Driver/Src/%.o Drivers/STM32F4xx_HAL_Driver/Src/%.su Drive
|
|||||||
clean: clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src
|
clean: clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src
|
||||||
|
|
||||||
clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src:
|
clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src:
|
||||||
-$(RM) ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.su
|
-$(RM) ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.su ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.cyclo ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.d ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o ./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.su
|
||||||
|
|
||||||
.PHONY: clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src
|
.PHONY: clean-Drivers-2f-STM32F4xx_HAL_Driver-2f-Src
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
"./Core/Src/24AA02E48.o"
|
"./Core/Src/dht11.o"
|
||||||
"./Core/Src/CS43L22.o"
|
"./Core/Src/external-temperature.o"
|
||||||
"./Core/Src/DNI.o"
|
"./Core/Src/external_temp.o"
|
||||||
"./Core/Src/LIS302DL.o"
|
|
||||||
"./Core/Src/PCA9685.o"
|
|
||||||
"./Core/Src/SST25VF016B.o"
|
|
||||||
"./Core/Src/lcd.o"
|
"./Core/Src/lcd.o"
|
||||||
"./Core/Src/main.o"
|
"./Core/Src/main.o"
|
||||||
"./Core/Src/stm32f4xx_hal_msp.o"
|
"./Core/Src/stm32f4xx_hal_msp.o"
|
||||||
@@ -23,13 +20,10 @@
|
|||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o"
|
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.o"
|
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.o"
|
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o"
|
||||||
|
|||||||
@@ -1,741 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32f4xx_hal_i2c.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32F4xx_HAL_I2C_H
|
|
||||||
#define __STM32F4xx_HAL_I2C_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32f4xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32F4xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Exported_Types I2C Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
|
|
||||||
* @brief I2C Configuration Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t ClockSpeed; /*!< Specifies the clock frequency.
|
|
||||||
This parameter must be set to a value lower than 400kHz */
|
|
||||||
|
|
||||||
uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
|
|
||||||
This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
|
|
||||||
|
|
||||||
uint32_t OwnAddress1; /*!< Specifies the first device own address.
|
|
||||||
This parameter can be a 7-bit or 10-bit address. */
|
|
||||||
|
|
||||||
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_addressing_mode */
|
|
||||||
|
|
||||||
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_dual_addressing_mode */
|
|
||||||
|
|
||||||
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
|
|
||||||
This parameter can be a 7-bit address. */
|
|
||||||
|
|
||||||
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_general_call_addressing_mode */
|
|
||||||
|
|
||||||
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_nostretch_mode */
|
|
||||||
|
|
||||||
} I2C_InitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_state_structure_definition HAL state structure definition
|
|
||||||
* @brief HAL State structure definition
|
|
||||||
* @note HAL I2C State value coding follow below described bitmap :
|
|
||||||
* b7-b6 Error information
|
|
||||||
* 00 : No Error
|
|
||||||
* 01 : Abort (Abort user request on going)
|
|
||||||
* 10 : Timeout
|
|
||||||
* 11 : Error
|
|
||||||
* b5 Peripheral initialization status
|
|
||||||
* 0 : Reset (Peripheral not initialized)
|
|
||||||
* 1 : Init done (Peripheral initialized and ready to use. HAL I2C Init function called)
|
|
||||||
* b4 (not used)
|
|
||||||
* x : Should be set to 0
|
|
||||||
* b3
|
|
||||||
* 0 : Ready or Busy (No Listen mode ongoing)
|
|
||||||
* 1 : Listen (Peripheral in Address Listen Mode)
|
|
||||||
* b2 Intrinsic process state
|
|
||||||
* 0 : Ready
|
|
||||||
* 1 : Busy (Peripheral busy with some configuration or internal operations)
|
|
||||||
* b1 Rx state
|
|
||||||
* 0 : Ready (no Rx operation ongoing)
|
|
||||||
* 1 : Busy (Rx operation ongoing)
|
|
||||||
* b0 Tx state
|
|
||||||
* 0 : Ready (no Tx operation ongoing)
|
|
||||||
* 1 : Busy (Tx operation ongoing)
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
|
||||||
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
|
|
||||||
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
|
|
||||||
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
|
||||||
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
|
|
||||||
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
|
|
||||||
|
|
||||||
} HAL_I2C_StateTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_mode_structure_definition HAL mode structure definition
|
|
||||||
* @brief HAL Mode structure definition
|
|
||||||
* @note HAL I2C Mode value coding follow below described bitmap :\n
|
|
||||||
* b7 (not used)\n
|
|
||||||
* x : Should be set to 0\n
|
|
||||||
* b6\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Memory (HAL I2C communication is in Memory Mode)\n
|
|
||||||
* b5\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Slave (HAL I2C communication is in Slave Mode)\n
|
|
||||||
* b4\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Master (HAL I2C communication is in Master Mode)\n
|
|
||||||
* b3-b2-b1-b0 (not used)\n
|
|
||||||
* xxxx : Should be set to 0000
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
|
|
||||||
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
|
|
||||||
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
|
|
||||||
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
|
|
||||||
|
|
||||||
} HAL_I2C_ModeTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Error_Code_definition I2C Error Code definition
|
|
||||||
* @brief I2C Error Code definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define HAL_I2C_ERROR_NONE 0x00000000U /*!< No error */
|
|
||||||
#define HAL_I2C_ERROR_BERR 0x00000001U /*!< BERR error */
|
|
||||||
#define HAL_I2C_ERROR_ARLO 0x00000002U /*!< ARLO error */
|
|
||||||
#define HAL_I2C_ERROR_AF 0x00000004U /*!< AF error */
|
|
||||||
#define HAL_I2C_ERROR_OVR 0x00000008U /*!< OVR error */
|
|
||||||
#define HAL_I2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
|
||||||
#define HAL_I2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout Error */
|
|
||||||
#define HAL_I2C_ERROR_SIZE 0x00000040U /*!< Size Management error */
|
|
||||||
#define HAL_I2C_ERROR_DMA_PARAM 0x00000080U /*!< DMA Parameter Error */
|
|
||||||
#define HAL_I2C_WRONG_START 0x00000200U /*!< Wrong start Error */
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define HAL_I2C_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid Callback error */
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
|
|
||||||
* @brief I2C handle Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
typedef struct __I2C_HandleTypeDef
|
|
||||||
#else
|
|
||||||
typedef struct
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
{
|
|
||||||
I2C_TypeDef *Instance; /*!< I2C registers base address */
|
|
||||||
|
|
||||||
I2C_InitTypeDef Init; /*!< I2C communication parameters */
|
|
||||||
|
|
||||||
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
|
|
||||||
|
|
||||||
uint16_t XferSize; /*!< I2C transfer size */
|
|
||||||
|
|
||||||
__IO uint16_t XferCount; /*!< I2C transfer counter */
|
|
||||||
|
|
||||||
__IO uint32_t XferOptions; /*!< I2C transfer options */
|
|
||||||
|
|
||||||
__IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
|
|
||||||
context for internal usage */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< I2C locking object */
|
|
||||||
|
|
||||||
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
|
|
||||||
|
|
||||||
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< I2C Error code */
|
|
||||||
|
|
||||||
__IO uint32_t Devaddress; /*!< I2C Target device address */
|
|
||||||
|
|
||||||
__IO uint32_t Memaddress; /*!< I2C Target memory address */
|
|
||||||
|
|
||||||
__IO uint32_t MemaddSize; /*!< I2C Target memory address size */
|
|
||||||
|
|
||||||
__IO uint32_t EventCount; /*!< I2C Event counter */
|
|
||||||
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
void (* MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Tx Transfer completed callback */
|
|
||||||
void (* MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Rx Transfer completed callback */
|
|
||||||
void (* SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Tx Transfer completed callback */
|
|
||||||
void (* SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Rx Transfer completed callback */
|
|
||||||
void (* ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Listen Complete callback */
|
|
||||||
void (* MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Tx Transfer completed callback */
|
|
||||||
void (* MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Rx Transfer completed callback */
|
|
||||||
void (* ErrorCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Error callback */
|
|
||||||
void (* AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Abort callback */
|
|
||||||
|
|
||||||
void (* AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< I2C Slave Address Match callback */
|
|
||||||
|
|
||||||
void (* MspInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp Init callback */
|
|
||||||
void (* MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp DeInit callback */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
} I2C_HandleTypeDef;
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback ID enumeration definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */
|
|
||||||
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */
|
|
||||||
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */
|
|
||||||
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */
|
|
||||||
|
|
||||||
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */
|
|
||||||
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */
|
|
||||||
|
|
||||||
} HAL_I2C_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback pointer definition
|
|
||||||
*/
|
|
||||||
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c); /*!< pointer to an I2C callback function */
|
|
||||||
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an I2C Address Match callback function */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Constants I2C Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_duty_cycle_in_fast_mode I2C duty cycle in fast mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DUTYCYCLE_2 0x00000000U
|
|
||||||
#define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_addressing_mode I2C addressing mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ADDRESSINGMODE_7BIT 0x00004000U
|
|
||||||
#define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | 0x00004000U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DUALADDRESS_DISABLE 0x00000000U
|
|
||||||
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_ENDUAL
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_GENERALCALL_DISABLE 0x00000000U
|
|
||||||
#define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_nostretch_mode I2C nostretch mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_NOSTRETCH_DISABLE 0x00000000U
|
|
||||||
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_MEMADD_SIZE_8BIT 0x00000001U
|
|
||||||
#define I2C_MEMADD_SIZE_16BIT 0x00000010U
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XferDirection_definition I2C XferDirection definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DIRECTION_RECEIVE 0x00000000U
|
|
||||||
#define I2C_DIRECTION_TRANSMIT 0x00000001U
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XferOptions_definition I2C XferOptions definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FIRST_FRAME 0x00000001U
|
|
||||||
#define I2C_FIRST_AND_NEXT_FRAME 0x00000002U
|
|
||||||
#define I2C_NEXT_FRAME 0x00000004U
|
|
||||||
#define I2C_FIRST_AND_LAST_FRAME 0x00000008U
|
|
||||||
#define I2C_LAST_FRAME_NO_STOP 0x00000010U
|
|
||||||
#define I2C_LAST_FRAME 0x00000020U
|
|
||||||
|
|
||||||
/* List of XferOptions in usage of :
|
|
||||||
* 1- Restart condition in all use cases (direction change or not)
|
|
||||||
*/
|
|
||||||
#define I2C_OTHER_FRAME (0x00AA0000U)
|
|
||||||
#define I2C_OTHER_AND_LAST_FRAME (0xAA000000U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
|
|
||||||
* @brief I2C Interrupt definition
|
|
||||||
* Elements values convention: 0xXXXXXXXX
|
|
||||||
* - XXXXXXXX : Interrupt control mask
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_IT_BUF I2C_CR2_ITBUFEN
|
|
||||||
#define I2C_IT_EVT I2C_CR2_ITEVTEN
|
|
||||||
#define I2C_IT_ERR I2C_CR2_ITERREN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Flag_definition I2C Flag definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define I2C_FLAG_OVR 0x00010800U
|
|
||||||
#define I2C_FLAG_AF 0x00010400U
|
|
||||||
#define I2C_FLAG_ARLO 0x00010200U
|
|
||||||
#define I2C_FLAG_BERR 0x00010100U
|
|
||||||
#define I2C_FLAG_TXE 0x00010080U
|
|
||||||
#define I2C_FLAG_RXNE 0x00010040U
|
|
||||||
#define I2C_FLAG_STOPF 0x00010010U
|
|
||||||
#define I2C_FLAG_ADD10 0x00010008U
|
|
||||||
#define I2C_FLAG_BTF 0x00010004U
|
|
||||||
#define I2C_FLAG_ADDR 0x00010002U
|
|
||||||
#define I2C_FLAG_SB 0x00010001U
|
|
||||||
#define I2C_FLAG_DUALF 0x00100080U
|
|
||||||
#define I2C_FLAG_GENCALL 0x00100010U
|
|
||||||
#define I2C_FLAG_TRA 0x00100004U
|
|
||||||
#define I2C_FLAG_BUSY 0x00100002U
|
|
||||||
#define I2C_FLAG_MSL 0x00100001U
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Macros I2C Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Reset I2C handle state.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
|
||||||
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \
|
|
||||||
(__HANDLE__)->MspInitCallback = NULL; \
|
|
||||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Enable or disable the specified I2C interrupts.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg I2C_IT_BUF: Buffer interrupt enable
|
|
||||||
* @arg I2C_IT_EVT: Event interrupt enable
|
|
||||||
* @arg I2C_IT_ERR: Error interrupt enable
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))
|
|
||||||
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
|
||||||
|
|
||||||
/** @brief Checks if the specified I2C interrupt source is enabled or disabled.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the I2C interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg I2C_IT_BUF: Buffer interrupt enable
|
|
||||||
* @arg I2C_IT_EVT: Event interrupt enable
|
|
||||||
* @arg I2C_IT_ERR: Error interrupt enable
|
|
||||||
* @retval The new state of __INTERRUPT__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Checks whether the specified I2C flag is set or not.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg I2C_FLAG_OVR: Overrun/Underrun flag
|
|
||||||
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
|
||||||
* @arg I2C_FLAG_ARLO: Arbitration lost flag
|
|
||||||
* @arg I2C_FLAG_BERR: Bus error flag
|
|
||||||
* @arg I2C_FLAG_TXE: Data register empty flag
|
|
||||||
* @arg I2C_FLAG_RXNE: Data register not empty flag
|
|
||||||
* @arg I2C_FLAG_STOPF: Stop detection flag
|
|
||||||
* @arg I2C_FLAG_ADD10: 10-bit header sent flag
|
|
||||||
* @arg I2C_FLAG_BTF: Byte transfer finished flag
|
|
||||||
* @arg I2C_FLAG_ADDR: Address sent flag
|
|
||||||
* Address matched flag
|
|
||||||
* @arg I2C_FLAG_SB: Start bit flag
|
|
||||||
* @arg I2C_FLAG_DUALF: Dual flag
|
|
||||||
* @arg I2C_FLAG_GENCALL: General call header flag
|
|
||||||
* @arg I2C_FLAG_TRA: Transmitter/Receiver flag
|
|
||||||
* @arg I2C_FLAG_BUSY: Bus busy flag
|
|
||||||
* @arg I2C_FLAG_MSL: Master/Slave flag
|
|
||||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U) ? \
|
|
||||||
(((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET) : \
|
|
||||||
(((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET))
|
|
||||||
|
|
||||||
/** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to clear.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
|
|
||||||
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
|
||||||
* @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
|
|
||||||
* @arg I2C_FLAG_BERR: Bus error flag
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK))
|
|
||||||
|
|
||||||
/** @brief Clears the I2C ADDR pending flag.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
__IO uint32_t tmpreg = 0x00U; \
|
|
||||||
tmpreg = (__HANDLE__)->Instance->SR1; \
|
|
||||||
tmpreg = (__HANDLE__)->Instance->SR2; \
|
|
||||||
UNUSED(tmpreg); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
/** @brief Clears the I2C STOPF pending flag.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
__IO uint32_t tmpreg = 0x00U; \
|
|
||||||
tmpreg = (__HANDLE__)->Instance->SR1; \
|
|
||||||
SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE); \
|
|
||||||
UNUSED(tmpreg); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
/** @brief Enable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
|
|
||||||
|
|
||||||
/** @brief Disable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Include I2C HAL Extension module */
|
|
||||||
#include "stm32f4xx_hal_i2c_ex.h"
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2C_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Initialization and de-initialization functions******************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/* Callbacks Register/UnRegister functions ***********************************/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID, pI2C_CallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions ****************************************************/
|
|
||||||
/******* Blocking mode: Polling */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: Interrupt */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: DMA */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
|
|
||||||
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
|
|
||||||
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State, Mode and Error functions *********************************/
|
|
||||||
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
|
|
||||||
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Constants I2C Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FLAG_MASK 0x0000FFFFU
|
|
||||||
#define I2C_MIN_PCLK_FREQ_STANDARD 2000000U /*!< 2 MHz */
|
|
||||||
#define I2C_MIN_PCLK_FREQ_FAST 4000000U /*!< 4 MHz */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Macros I2C Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define I2C_MIN_PCLK_FREQ(__PCLK__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__PCLK__) < I2C_MIN_PCLK_FREQ_STANDARD) : ((__PCLK__) < I2C_MIN_PCLK_FREQ_FAST))
|
|
||||||
#define I2C_CCR_CALCULATION(__PCLK__, __SPEED__, __COEFF__) (((((__PCLK__) - 1U)/((__SPEED__) * (__COEFF__))) + 1U) & I2C_CCR_CCR)
|
|
||||||
#define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000U)
|
|
||||||
#define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
|
|
||||||
#define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) ((I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U) < 4U)? 4U:I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U))
|
|
||||||
#define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 3U) : (I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 25U) | I2C_DUTYCYCLE_16_9))
|
|
||||||
#define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000U)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \
|
|
||||||
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U)? 1U : \
|
|
||||||
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
|
|
||||||
|
|
||||||
#define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (uint8_t)(~I2C_OAR1_ADD0)))
|
|
||||||
#define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0))
|
|
||||||
|
|
||||||
#define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
|
||||||
#define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)0x00F0)))
|
|
||||||
#define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)(0x00F1))))
|
|
||||||
|
|
||||||
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8)))
|
|
||||||
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
|
||||||
|
|
||||||
/** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \
|
|
||||||
((CYCLE) == I2C_DUTYCYCLE_16_9))
|
|
||||||
#define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \
|
|
||||||
((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
|
|
||||||
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
|
|
||||||
((ADDRESS) == I2C_DUALADDRESS_ENABLE))
|
|
||||||
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
|
|
||||||
((CALL) == I2C_GENERALCALL_ENABLE))
|
|
||||||
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
|
|
||||||
((STRETCH) == I2C_NOSTRETCH_ENABLE))
|
|
||||||
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
|
|
||||||
((SIZE) == I2C_MEMADD_SIZE_16BIT))
|
|
||||||
#define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0U) && ((SPEED) <= 400000U))
|
|
||||||
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & 0xFFFFFC00U) == 0U)
|
|
||||||
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & 0xFFFFFF01U) == 0U)
|
|
||||||
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME_NO_STOP) || \
|
|
||||||
IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST))
|
|
||||||
|
|
||||||
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || \
|
|
||||||
((REQUEST) == I2C_OTHER_AND_LAST_FRAME))
|
|
||||||
|
|
||||||
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET)
|
|
||||||
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Functions I2C Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __STM32F4xx_HAL_I2C_H */
|
|
||||||
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32f4xx_hal_i2c_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL Extension module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32F4xx_HAL_I2C_EX_H
|
|
||||||
#define __STM32F4xx_HAL_I2C_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32f4xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32F4xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Constants I2C Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Analog_Filter I2C Analog Filter
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ANALOGFILTER_ENABLE 0x00000000U
|
|
||||||
#define I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral Control functions ************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter);
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Constants I2C Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Macros I2C Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \
|
|
||||||
((FILTER) == I2C_ANALOGFILTER_DISABLE))
|
|
||||||
#define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32F4xx_HAL_I2C_EX_H */
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,729 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32f4xx_hal_spi.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of SPI HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32F4xx_HAL_SPI_H
|
|
||||||
#define STM32F4xx_HAL_SPI_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32f4xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32F4xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup SPI
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup SPI_Exported_Types SPI Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SPI Configuration Structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Mode; /*!< Specifies the SPI operating mode.
|
|
||||||
This parameter can be a value of @ref SPI_Mode */
|
|
||||||
|
|
||||||
uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
|
|
||||||
This parameter can be a value of @ref SPI_Direction */
|
|
||||||
|
|
||||||
uint32_t DataSize; /*!< Specifies the SPI data size.
|
|
||||||
This parameter can be a value of @ref SPI_Data_Size */
|
|
||||||
|
|
||||||
uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
|
|
||||||
This parameter can be a value of @ref SPI_Clock_Polarity */
|
|
||||||
|
|
||||||
uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
|
|
||||||
This parameter can be a value of @ref SPI_Clock_Phase */
|
|
||||||
|
|
||||||
uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
|
|
||||||
hardware (NSS pin) or by software using the SSI bit.
|
|
||||||
This parameter can be a value of @ref SPI_Slave_Select_management */
|
|
||||||
|
|
||||||
uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
|
|
||||||
used to configure the transmit and receive SCK clock.
|
|
||||||
This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
|
||||||
@note The communication clock is derived from the master
|
|
||||||
clock. The slave clock does not need to be set. */
|
|
||||||
|
|
||||||
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
|
|
||||||
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
|
|
||||||
|
|
||||||
uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not.
|
|
||||||
This parameter can be a value of @ref SPI_TI_mode */
|
|
||||||
|
|
||||||
uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
|
|
||||||
This parameter can be a value of @ref SPI_CRC_Calculation */
|
|
||||||
|
|
||||||
uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
|
|
||||||
This parameter must be an odd number between Min_Data = 1 and Max_Data = 65535 */
|
|
||||||
} SPI_InitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL SPI State structure definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */
|
|
||||||
HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
|
||||||
HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
|
||||||
HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
|
|
||||||
HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
|
|
||||||
HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
|
|
||||||
HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */
|
|
||||||
HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */
|
|
||||||
} HAL_SPI_StateTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SPI handle Structure definition
|
|
||||||
*/
|
|
||||||
typedef struct __SPI_HandleTypeDef
|
|
||||||
{
|
|
||||||
SPI_TypeDef *Instance; /*!< SPI registers base address */
|
|
||||||
|
|
||||||
SPI_InitTypeDef Init; /*!< SPI communication parameters */
|
|
||||||
|
|
||||||
const uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
|
|
||||||
|
|
||||||
uint16_t TxXferSize; /*!< SPI Tx Transfer size */
|
|
||||||
|
|
||||||
__IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
|
|
||||||
|
|
||||||
uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
|
|
||||||
|
|
||||||
uint16_t RxXferSize; /*!< SPI Rx Transfer size */
|
|
||||||
|
|
||||||
__IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
|
|
||||||
|
|
||||||
void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */
|
|
||||||
|
|
||||||
void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
|
||||||
|
|
||||||
__IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< SPI Error code */
|
|
||||||
|
|
||||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
|
||||||
void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */
|
|
||||||
void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */
|
|
||||||
void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */
|
|
||||||
void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */
|
|
||||||
void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */
|
|
||||||
void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */
|
|
||||||
void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */
|
|
||||||
void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */
|
|
||||||
void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */
|
|
||||||
void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
|
||||||
} SPI_HandleTypeDef;
|
|
||||||
|
|
||||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
|
||||||
/**
|
|
||||||
* @brief HAL SPI Callback ID enumeration definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */
|
|
||||||
HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */
|
|
||||||
HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */
|
|
||||||
HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */
|
|
||||||
HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */
|
|
||||||
HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */
|
|
||||||
HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */
|
|
||||||
HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */
|
|
||||||
HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */
|
|
||||||
HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */
|
|
||||||
|
|
||||||
} HAL_SPI_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL SPI Callback pointer definition
|
|
||||||
*/
|
|
||||||
typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup SPI_Exported_Constants SPI Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Error_Code SPI Error Code
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */
|
|
||||||
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */
|
|
||||||
#define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */
|
|
||||||
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */
|
|
||||||
#define HAL_SPI_ERROR_FRE (0x00000008U) /*!< FRE error */
|
|
||||||
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
|
||||||
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY Flag */
|
|
||||||
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */
|
|
||||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
|
||||||
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */
|
|
||||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Mode SPI Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_MODE_SLAVE (0x00000000U)
|
|
||||||
#define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Direction SPI Direction Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_DIRECTION_2LINES (0x00000000U)
|
|
||||||
#define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
|
|
||||||
#define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Data_Size SPI Data Size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_DATASIZE_8BIT (0x00000000U)
|
|
||||||
#define SPI_DATASIZE_16BIT SPI_CR1_DFF
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Clock_Polarity SPI Clock Polarity
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_POLARITY_LOW (0x00000000U)
|
|
||||||
#define SPI_POLARITY_HIGH SPI_CR1_CPOL
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Clock_Phase SPI Clock Phase
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_PHASE_1EDGE (0x00000000U)
|
|
||||||
#define SPI_PHASE_2EDGE SPI_CR1_CPHA
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Slave_Select_management SPI Slave Select Management
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_NSS_SOFT SPI_CR1_SSM
|
|
||||||
#define SPI_NSS_HARD_INPUT (0x00000000U)
|
|
||||||
#define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_BAUDRATEPRESCALER_2 (0x00000000U)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1)
|
|
||||||
#define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_FIRSTBIT_MSB (0x00000000U)
|
|
||||||
#define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_TI_mode SPI TI Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_TIMODE_DISABLE (0x00000000U)
|
|
||||||
#define SPI_TIMODE_ENABLE SPI_CR2_FRF
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_CRC_Calculation SPI CRC Calculation
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_CRCCALCULATION_DISABLE (0x00000000U)
|
|
||||||
#define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_IT_TXE SPI_CR2_TXEIE
|
|
||||||
#define SPI_IT_RXNE SPI_CR2_RXNEIE
|
|
||||||
#define SPI_IT_ERR SPI_CR2_ERRIE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SPI_Flags_definition SPI Flags Definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
|
|
||||||
#define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
|
|
||||||
#define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
|
|
||||||
#define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
|
|
||||||
#define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
|
|
||||||
#define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
|
|
||||||
#define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */
|
|
||||||
#define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE | SPI_SR_BSY | SPI_SR_CRCERR\
|
|
||||||
| SPI_SR_MODF | SPI_SR_OVR | SPI_SR_FRE)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
/** @defgroup SPI_Exported_Macros SPI Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Reset SPI handle state.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
|
||||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
|
||||||
(__HANDLE__)->State = HAL_SPI_STATE_RESET; \
|
|
||||||
(__HANDLE__)->MspInitCallback = NULL; \
|
|
||||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
|
|
||||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
|
||||||
|
|
||||||
/** @brief Enable the specified SPI interrupts.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
|
||||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
|
||||||
* @arg SPI_IT_ERR: Error interrupt enable
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
|
||||||
|
|
||||||
/** @brief Disable the specified SPI interrupts.
|
|
||||||
* @param __HANDLE__ specifies the SPI handle.
|
|
||||||
* This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
|
||||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
|
||||||
* @arg SPI_IT_ERR: Error interrupt enable
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
|
||||||
|
|
||||||
/** @brief Check whether the specified SPI interrupt source is enabled or not.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
|
||||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
|
||||||
* @arg SPI_IT_ERR: Error interrupt enable
|
|
||||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\
|
|
||||||
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Check whether the specified SPI flag is set or not.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
|
||||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
|
||||||
* @arg SPI_FLAG_CRCERR: CRC error flag
|
|
||||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
|
||||||
* @arg SPI_FLAG_OVR: Overrun flag
|
|
||||||
* @arg SPI_FLAG_BSY: Busy flag
|
|
||||||
* @arg SPI_FLAG_FRE: Frame format error flag
|
|
||||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
|
||||||
|
|
||||||
/** @brief Clear the SPI CRCERR pending flag.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
|
|
||||||
|
|
||||||
/** @brief Clear the SPI MODF pending flag.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
__IO uint32_t tmpreg_modf = 0x00U; \
|
|
||||||
tmpreg_modf = (__HANDLE__)->Instance->SR; \
|
|
||||||
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \
|
|
||||||
UNUSED(tmpreg_modf); \
|
|
||||||
} while(0U)
|
|
||||||
|
|
||||||
/** @brief Clear the SPI OVR pending flag.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
__IO uint32_t tmpreg_ovr = 0x00U; \
|
|
||||||
tmpreg_ovr = (__HANDLE__)->Instance->DR; \
|
|
||||||
tmpreg_ovr = (__HANDLE__)->Instance->SR; \
|
|
||||||
UNUSED(tmpreg_ovr); \
|
|
||||||
} while(0U)
|
|
||||||
|
|
||||||
/** @brief Clear the SPI FRE pending flag.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
__IO uint32_t tmpreg_fre = 0x00U; \
|
|
||||||
tmpreg_fre = (__HANDLE__)->Instance->SR; \
|
|
||||||
UNUSED(tmpreg_fre); \
|
|
||||||
}while(0U)
|
|
||||||
|
|
||||||
/** @brief Enable the SPI peripheral.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
|
||||||
|
|
||||||
/** @brief Disable the SPI peripheral.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup SPI_Private_Macros SPI Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Set the SPI transmit-only mode.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
|
||||||
|
|
||||||
/** @brief Set the SPI receive-only mode.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
|
||||||
|
|
||||||
/** @brief Reset the CRC calculation of the SPI.
|
|
||||||
* @param __HANDLE__ specifies the SPI Handle.
|
|
||||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define SPI_RESET_CRC(__HANDLE__) do{CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);\
|
|
||||||
SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);}while(0U)
|
|
||||||
|
|
||||||
/** @brief Check whether the specified SPI flag is set or not.
|
|
||||||
* @param __SR__ copy of SPI SR register.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
|
||||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
|
||||||
* @arg SPI_FLAG_CRCERR: CRC error flag
|
|
||||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
|
||||||
* @arg SPI_FLAG_OVR: Overrun flag
|
|
||||||
* @arg SPI_FLAG_BSY: Busy flag
|
|
||||||
* @arg SPI_FLAG_FRE: Frame format error flag
|
|
||||||
* @retval SET or RESET.
|
|
||||||
*/
|
|
||||||
#define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == \
|
|
||||||
((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Check whether the specified SPI Interrupt is set or not.
|
|
||||||
* @param __CR2__ copy of SPI CR2 register.
|
|
||||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
|
||||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
|
||||||
* @arg SPI_IT_ERR: Error interrupt enable
|
|
||||||
* @retval SET or RESET.
|
|
||||||
*/
|
|
||||||
#define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == \
|
|
||||||
(__INTERRUPT__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Mode parameter is in allowed range.
|
|
||||||
* @param __MODE__ specifies the SPI Mode.
|
|
||||||
* This parameter can be a value of @ref SPI_Mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \
|
|
||||||
((__MODE__) == SPI_MODE_MASTER))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Direction Mode parameter is in allowed range.
|
|
||||||
* @param __MODE__ specifies the SPI Direction Mode.
|
|
||||||
* This parameter can be a value of @ref SPI_Direction
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
|
||||||
((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \
|
|
||||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Direction Mode parameter is 2 lines.
|
|
||||||
* @param __MODE__ specifies the SPI Direction Mode.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES)
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines.
|
|
||||||
* @param __MODE__ specifies the SPI Direction Mode.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
|
||||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Data Size parameter is in allowed range.
|
|
||||||
* @param __DATASIZE__ specifies the SPI Data Size.
|
|
||||||
* This parameter can be a value of @ref SPI_Data_Size
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \
|
|
||||||
((__DATASIZE__) == SPI_DATASIZE_8BIT))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Serial clock steady state parameter is in allowed range.
|
|
||||||
* @param __CPOL__ specifies the SPI serial clock steady state.
|
|
||||||
* This parameter can be a value of @ref SPI_Clock_Polarity
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
|
|
||||||
((__CPOL__) == SPI_POLARITY_HIGH))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Clock Phase parameter is in allowed range.
|
|
||||||
* @param __CPHA__ specifies the SPI Clock Phase.
|
|
||||||
* This parameter can be a value of @ref SPI_Clock_Phase
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
|
|
||||||
((__CPHA__) == SPI_PHASE_2EDGE))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Slave Select parameter is in allowed range.
|
|
||||||
* @param __NSS__ specifies the SPI Slave Select management parameter.
|
|
||||||
* This parameter can be a value of @ref SPI_Slave_Select_management
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \
|
|
||||||
((__NSS__) == SPI_NSS_HARD_INPUT) || \
|
|
||||||
((__NSS__) == SPI_NSS_HARD_OUTPUT))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI Baudrate prescaler parameter is in allowed range.
|
|
||||||
* @param __PRESCALER__ specifies the SPI Baudrate prescaler.
|
|
||||||
* This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \
|
|
||||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI MSB LSB transmission parameter is in allowed range.
|
|
||||||
* @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit).
|
|
||||||
* This parameter can be a value of @ref SPI_MSB_LSB_transmission
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \
|
|
||||||
((__BIT__) == SPI_FIRSTBIT_LSB))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI TI mode parameter is in allowed range.
|
|
||||||
* @param __MODE__ specifies the SPI TI mode.
|
|
||||||
* This parameter can be a value of @ref SPI_TI_mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_TIMODE(__MODE__) (((__MODE__) == SPI_TIMODE_DISABLE) || \
|
|
||||||
((__MODE__) == SPI_TIMODE_ENABLE))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI CRC calculation enabled state is in allowed range.
|
|
||||||
* @param __CALCULATION__ specifies the SPI CRC calculation enable state.
|
|
||||||
* This parameter can be a value of @ref SPI_CRC_Calculation
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \
|
|
||||||
((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE))
|
|
||||||
|
|
||||||
/** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range.
|
|
||||||
* @param __POLYNOMIAL__ specifies the SPI polynomial value to be used for the CRC calculation.
|
|
||||||
* This parameter must be a number between Min_Data = 0 and Max_Data = 65535
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && \
|
|
||||||
((__POLYNOMIAL__) <= 0xFFFFU) && \
|
|
||||||
(((__POLYNOMIAL__)&0x1U) != 0U))
|
|
||||||
|
|
||||||
/** @brief Checks if DMA handle is valid.
|
|
||||||
* @param __HANDLE__ specifies a DMA Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup SPI_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup SPI_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Initialization/de-initialization functions ********************************/
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
|
|
||||||
|
|
||||||
/* Callbacks Register/UnRegister functions ***********************************/
|
|
||||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
|
||||||
HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID,
|
|
||||||
pSPI_CallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID);
|
|
||||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup SPI_Exported_Functions_Group2
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* I/O operation functions ***************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
|
||||||
uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
|
|
||||||
/* Transfer Abort functions */
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi);
|
|
||||||
|
|
||||||
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup SPI_Exported_Functions_Group3
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State and Error functions ***************************************/
|
|
||||||
HAL_SPI_StateTypeDef HAL_SPI_GetState(const SPI_HandleTypeDef *hspi);
|
|
||||||
uint32_t HAL_SPI_GetError(const SPI_HandleTypeDef *hspi);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32F4xx_HAL_SPI_H */
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,182 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32f4xx_hal_i2c_ex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief I2C Extension HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of I2C extension peripheral:
|
|
||||||
* + Extension features functions
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### I2C peripheral extension features #####
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
[..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/
|
|
||||||
429xx/439xx devices contains the following additional features :
|
|
||||||
|
|
||||||
(+) Possibility to disable or enable Analog Noise Filter
|
|
||||||
(+) Use of a configured Digital Noise Filter
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..] This driver provides functions to configure Noise Filter
|
|
||||||
(#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config()
|
|
||||||
(#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config()
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32f4xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32F4xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx I2CEx
|
|
||||||
* @brief I2C HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_I2C_MODULE_ENABLED
|
|
||||||
|
|
||||||
#if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Functions I2C Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions_Group1 Extension features functions
|
|
||||||
* @brief Extension features functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Extension features functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure Noise Filters
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures I2C Analog noise filter.
|
|
||||||
* @param hi2c pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param AnalogFilter new state of the Analog filter.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Reset I2Cx ANOFF bit */
|
|
||||||
hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF);
|
|
||||||
|
|
||||||
/* Disable the analog filter */
|
|
||||||
hi2c->Instance->FLTR |= AnalogFilter;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures I2C Digital noise filter.
|
|
||||||
* @param hi2c pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param DigitalFilter Coefficient of digital noise filter between 0x00 and 0x0F.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
|
|
||||||
{
|
|
||||||
uint16_t tmpreg = 0;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Get the old register value */
|
|
||||||
tmpreg = hi2c->Instance->FLTR;
|
|
||||||
|
|
||||||
/* Reset I2Cx DNF bit [3:0] */
|
|
||||||
tmpreg &= ~(I2C_FLTR_DNF);
|
|
||||||
|
|
||||||
/* Set I2Cx DNF coefficient */
|
|
||||||
tmpreg |= DigitalFilter;
|
|
||||||
|
|
||||||
/* Store the new register value */
|
|
||||||
hi2c->Instance->FLTR = tmpreg;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
88
test1.ioc
88
test1.ioc
@@ -16,42 +16,28 @@ KeepUserPlacement=false
|
|||||||
Mcu.CPN=STM32F407VGT6
|
Mcu.CPN=STM32F407VGT6
|
||||||
Mcu.Family=STM32F4
|
Mcu.Family=STM32F4
|
||||||
Mcu.IP0=ADC1
|
Mcu.IP0=ADC1
|
||||||
Mcu.IP1=I2C1
|
Mcu.IP1=NVIC
|
||||||
Mcu.IP2=NVIC
|
Mcu.IP2=RCC
|
||||||
Mcu.IP3=RCC
|
Mcu.IP3=SYS
|
||||||
Mcu.IP4=SPI1
|
Mcu.IPNb=4
|
||||||
Mcu.IP5=SYS
|
|
||||||
Mcu.IPNb=6
|
|
||||||
Mcu.Name=STM32F407V(E-G)Tx
|
Mcu.Name=STM32F407V(E-G)Tx
|
||||||
Mcu.Package=LQFP100
|
Mcu.Package=LQFP100
|
||||||
Mcu.Pin0=PA0-WKUP
|
Mcu.Pin0=PA0-WKUP
|
||||||
Mcu.Pin1=PA5
|
Mcu.Pin1=PB1
|
||||||
Mcu.Pin10=PD12
|
Mcu.Pin10=PD12
|
||||||
Mcu.Pin11=PD13
|
Mcu.Pin11=PD13
|
||||||
Mcu.Pin12=PD14
|
Mcu.Pin12=PD14
|
||||||
Mcu.Pin13=PD15
|
Mcu.Pin13=PD15
|
||||||
Mcu.Pin14=PC6
|
Mcu.Pin14=VP_SYS_VS_Systick
|
||||||
Mcu.Pin15=PC8
|
Mcu.Pin2=PE7
|
||||||
Mcu.Pin16=PC9
|
Mcu.Pin3=PE10
|
||||||
Mcu.Pin17=PA15
|
Mcu.Pin4=PE11
|
||||||
Mcu.Pin18=PC11
|
Mcu.Pin5=PE12
|
||||||
Mcu.Pin19=PD4
|
Mcu.Pin6=PE13
|
||||||
Mcu.Pin2=PB1
|
Mcu.Pin7=PE14
|
||||||
Mcu.Pin20=PD7
|
Mcu.Pin8=PE15
|
||||||
Mcu.Pin21=PB4
|
Mcu.Pin9=PD11
|
||||||
Mcu.Pin22=PB5
|
Mcu.PinsNb=15
|
||||||
Mcu.Pin23=PB6
|
|
||||||
Mcu.Pin24=PB7
|
|
||||||
Mcu.Pin25=PB9
|
|
||||||
Mcu.Pin26=VP_SYS_VS_Systick
|
|
||||||
Mcu.Pin3=PE7
|
|
||||||
Mcu.Pin4=PE10
|
|
||||||
Mcu.Pin5=PE11
|
|
||||||
Mcu.Pin6=PE12
|
|
||||||
Mcu.Pin7=PE13
|
|
||||||
Mcu.Pin8=PE14
|
|
||||||
Mcu.Pin9=PE15
|
|
||||||
Mcu.PinsNb=27
|
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F407VGTx
|
Mcu.UserName=STM32F407VGTx
|
||||||
@@ -59,6 +45,7 @@ MxCube.Version=6.12.1
|
|||||||
MxDb.Version=DB.6.0.121
|
MxDb.Version=DB.6.0.121
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.EXTI0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.ForceEnableDMAVector=true
|
NVIC.ForceEnableDMAVector=true
|
||||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
@@ -69,34 +56,11 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
PA0-WKUP.Locked=true
|
PA0-WKUP.Locked=true
|
||||||
PA0-WKUP.Signal=GPIO_Input
|
PA0-WKUP.Signal=GPXTI0
|
||||||
PA15.Locked=true
|
|
||||||
PA15.Signal=GPIO_Input
|
|
||||||
PA5.Mode=Full_Duplex_Master
|
|
||||||
PA5.Signal=SPI1_SCK
|
|
||||||
PB1.Locked=true
|
PB1.Locked=true
|
||||||
PB1.Signal=ADCx_IN9
|
PB1.Signal=ADCx_IN9
|
||||||
PB4.Locked=true
|
PD11.Locked=true
|
||||||
PB4.Mode=Full_Duplex_Master
|
PD11.Signal=GPIO_Output
|
||||||
PB4.Signal=SPI1_MISO
|
|
||||||
PB5.Locked=true
|
|
||||||
PB5.Mode=Full_Duplex_Master
|
|
||||||
PB5.Signal=SPI1_MOSI
|
|
||||||
PB6.Mode=I2C
|
|
||||||
PB6.Signal=I2C1_SCL
|
|
||||||
PB7.Locked=true
|
|
||||||
PB7.Signal=GPIO_Output
|
|
||||||
PB9.Locked=true
|
|
||||||
PB9.Mode=I2C
|
|
||||||
PB9.Signal=I2C1_SDA
|
|
||||||
PC11.Locked=true
|
|
||||||
PC11.Signal=GPIO_Input
|
|
||||||
PC6.Locked=true
|
|
||||||
PC6.Signal=GPIO_Input
|
|
||||||
PC8.Locked=true
|
|
||||||
PC8.Signal=GPIO_Input
|
|
||||||
PC9.Locked=true
|
|
||||||
PC9.Signal=GPIO_Input
|
|
||||||
PD12.Locked=true
|
PD12.Locked=true
|
||||||
PD12.Signal=GPIO_Output
|
PD12.Signal=GPIO_Output
|
||||||
PD13.Locked=true
|
PD13.Locked=true
|
||||||
@@ -105,10 +69,6 @@ PD14.Locked=true
|
|||||||
PD14.Signal=GPIO_Output
|
PD14.Signal=GPIO_Output
|
||||||
PD15.Locked=true
|
PD15.Locked=true
|
||||||
PD15.Signal=GPIO_Output
|
PD15.Signal=GPIO_Output
|
||||||
PD4.Locked=true
|
|
||||||
PD4.Signal=GPIO_Output
|
|
||||||
PD7.Locked=true
|
|
||||||
PD7.Signal=GPIO_Output
|
|
||||||
PE10.Locked=true
|
PE10.Locked=true
|
||||||
PE10.Signal=GPIO_Output
|
PE10.Signal=GPIO_Output
|
||||||
PE11.Locked=true
|
PE11.Locked=true
|
||||||
@@ -154,7 +114,7 @@ ProjectManager.ToolChainLocation=
|
|||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true
|
||||||
RCC.AHBFreq_Value=16000000
|
RCC.AHBFreq_Value=16000000
|
||||||
RCC.APB1Freq_Value=16000000
|
RCC.APB1Freq_Value=16000000
|
||||||
RCC.APB1TimFreq_Value=16000000
|
RCC.APB1TimFreq_Value=16000000
|
||||||
@@ -183,12 +143,8 @@ RCC.VCOOutputFreq_Value=192000000
|
|||||||
RCC.VcooutputI2S=96000000
|
RCC.VcooutputI2S=96000000
|
||||||
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
||||||
SH.ADCx_IN9.ConfNb=1
|
SH.ADCx_IN9.ConfNb=1
|
||||||
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
SH.GPXTI0.0=GPIO_EXTI0
|
||||||
SPI1.CalculateBaudRate=1000.0 KBits/s
|
SH.GPXTI0.ConfNb=1
|
||||||
SPI1.Direction=SPI_DIRECTION_2LINES
|
|
||||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
|
|
||||||
SPI1.Mode=SPI_MODE_MASTER
|
|
||||||
SPI1.VirtualType=VM_MASTER
|
|
||||||
VP_SYS_VS_Systick.Mode=SysTick
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
board=custom
|
board=custom
|
||||||
|
|||||||
Reference in New Issue
Block a user