|
@@ -11,11 +11,17 @@
|
|
|
*/
|
|
|
|
|
|
#include "common_config.h"
|
|
|
-#include "stm32f2xx.h"
|
|
|
-#include "stm32f2xx_dma.h"
|
|
|
+#include "stm32f4xx.h"
|
|
|
+#include "stm32f4xx_dma.h"
|
|
|
#include "usart.h"
|
|
|
#include "gpio.h"
|
|
|
#include "onewire.h"
|
|
|
+#ifdef PRINTF_STDLIB
|
|
|
+#include <stdio.h>
|
|
|
+#endif
|
|
|
+#ifdef PRINTF_CUSTOM
|
|
|
+#include "tinystdio.h"
|
|
|
+#endif
|
|
|
|
|
|
/* Force remove debug output */
|
|
|
#undef DBG
|
|
@@ -37,15 +43,15 @@ typedef struct {
|
|
|
USART_TypeDef *uart_addr;
|
|
|
DMA_InitTypeDef DMA_InitStructureTx;
|
|
|
DMA_InitTypeDef DMA_InitStructureRx;
|
|
|
- sensorBuf[DALLAS_BUF_SIZE];
|
|
|
+ uint8_t sensorBuf[DALLAS_BUF_SIZE];
|
|
|
}ow_sensor_t;
|
|
|
|
|
|
ow_sensor_t ow_sensor[MAX_T_SENSORS];
|
|
|
|
|
|
-#define T_SENSOR_ADD(sensor_num, ow_line, uart_addr) \
|
|
|
+#define T_SENSOR_ADD(sensor_num, ow_line, uart) \
|
|
|
do { \
|
|
|
+ ow_sensor[sensor_num].uart_addr = uart; \
|
|
|
ow_sensor[sensor_num].ow_pin = ow_line; \
|
|
|
- ow_sensor[sensor_num].uart_addr = uart_addr; \
|
|
|
} while (0);
|
|
|
|
|
|
/**
|
|
@@ -54,10 +60,10 @@ ow_sensor_t ow_sensor[MAX_T_SENSORS];
|
|
|
*/
|
|
|
void DALLAS_Init()
|
|
|
{
|
|
|
- for (uint8_t i = 0; i < MAX_T_SENSORS; i ++) {
|
|
|
-#define XTSENSOR(sensor_num, ow_line, uart_addrm) T_SENSOR_ADD(sensor_num, ow_line, uart_addr);
|
|
|
+#define XTSENSOR(sensor_num, ow_line, uart) T_SENSOR_ADD(sensor_num, ow_line, uart);
|
|
|
T_SENSOR_TABLE
|
|
|
#undef XTSENSOR
|
|
|
+ for (uint8_t i = 0; i < MAX_T_SENSORS; i ++) {
|
|
|
uart_hw_init(ow_sensor[i].uart_addr, DALLAS_SENSOR_UART_BAUD, DALLAS_SENSOR_UART_WORD_LEN,
|
|
|
DALLAS_SENSOR_UART_PARITY, DALLAS_SENSOR_UART_STOP_BIT);
|
|
|
}
|
|
@@ -134,7 +140,7 @@ void DALLAS_DmaInit(void)
|
|
|
DMA_DeInit(TxDMA_Stream);
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_Channel = TxDMA_Stream;
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_PeripheralBaseAddr = &ow_sensor[i].uart_addr->DR;
|
|
|
- ow_sensor[i].DMA_InitStructureTx.DMA_Memory0BaseAddr = (uint32_t)&Dow_sensor[i].sensorBuf;
|
|
|
+ ow_sensor[i].DMA_InitStructureTx.DMA_Memory0BaseAddr = (uint32_t)&ow_sensor[i].sensorBuf;
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_DIR = DMA_DIR_MemoryToPeripheral;
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_BufferSize = DALLAS_BUF_SIZE;
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
|
@@ -144,7 +150,7 @@ void DALLAS_DmaInit(void)
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_Mode = DMA_Mode_Normal;
|
|
|
ow_sensor[i].DMA_InitStructureTx.DMA_Priority = DMA_Priority_Medium;
|
|
|
|
|
|
- DMA_Init(TxDMA_Stream, &ow_sensor[i].DMA_InitStructureTx.);
|
|
|
+ DMA_Init(TxDMA_Stream, &ow_sensor[i].DMA_InitStructureTx);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -155,9 +161,9 @@ void DALLAS_DmaInit(void)
|
|
|
void DALLAS_OutSetAsPower(t_sensor_list_t sensor)
|
|
|
{
|
|
|
gpio_pindef_t *pin = &gpio_pins[ow_sensor[sensor].ow_pin];
|
|
|
- gpio_hw_config_pin(pin->port, pin->pin, GPIO_MODE_OUT_CFG | GPIO_TYPE_PP_CFG) |
|
|
|
+ gpio_hw_config_pin(pin->port, pin->pin, (GPIO_MODE_OUT_CFG | GPIO_TYPE_PP_CFG |
|
|
|
GPIO_SPEED_HIGH_CFG));
|
|
|
- gpio_set(id, GPIO_SET);
|
|
|
+ gpio_set(ow_sensor[sensor].ow_pin, GPIO_SET);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -168,7 +174,7 @@ void DALLAS_OutSetAsTX(t_sensor_list_t sensor)
|
|
|
{
|
|
|
gpio_pindef_t *pin = &gpio_pins[ow_sensor[sensor].ow_pin];
|
|
|
uint8_t af_n = (uint8_t)(pin->flags >> _GPIO_AF_SHIFT);
|
|
|
- gpio_connect_af(id, af_n);
|
|
|
+ gpio_connect_af(ow_sensor[sensor].ow_pin, af_n);
|
|
|
gpio_hw_config_pin(pin->port, pin->pin, GPIO_MODE_AF_CFG |
|
|
|
GPIO_SPEED_HIGH_CFG);
|
|
|
}
|