Start implementation of onewire temperature sensor interface
This commit is contained in:
		@@ -23,7 +23,9 @@
 | 
			
		||||
 | 
			
		||||
#include <stm-periph/uart.h>
 | 
			
		||||
 | 
			
		||||
int onewire_if_init_uart(struct stm_uart *uart);
 | 
			
		||||
int onewire_if_init_uart(struct stm_uart *uart, uint32_t brr_val, USART_TypeDef *onewire_uart, volatile uint32_t *rcc_reg, uint8_t rcc_bit_num);
 | 
			
		||||
 | 
			
		||||
void onewire_if_disable(struct stm_uart *uart);
 | 
			
		||||
 | 
			
		||||
int onewire_if_send_byte(struct stm_uart *uart);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,30 @@
 | 
			
		||||
* If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#ifndef __ONEWIRE_TEMP_SENSORS_H__
 | 
			
		||||
#define __ONEWIRE_TEMP_SENSORS_H__
 | 
			
		||||
 | 
			
		||||
#define ONEWIRE_TEMP_PORT GPIOB
 | 
			
		||||
#define ONEWIRE_TEMP_RCC_MASK RCC_AHB1ENR_GPIOBEN
 | 
			
		||||
#define ONEWIRE_TEMP_TX_PIN 10U
 | 
			
		||||
#define ONEWIRE_TEMP_RX_PIN 11U
 | 
			
		||||
#define ONEWIRE_TEMP_AF_NUM 7U
 | 
			
		||||
 | 
			
		||||
#define ONEWIRE_UART_DEV USART3
 | 
			
		||||
 | 
			
		||||
void onewire_temp_sensors_setup_hw();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief onewire_temp_sensors_discover
 | 
			
		||||
 * @param id_list
 | 
			
		||||
 * @param list_len
 | 
			
		||||
 * @return Negative: error, >= 0: amount of discovered sensors
 | 
			
		||||
 */
 | 
			
		||||
int onewire_temp_sensors_discover(uint32_t *id_list, size_t list_len);
 | 
			
		||||
 | 
			
		||||
float onewire_temp_sensor_read_temp(uint32_t id);
 | 
			
		||||
 | 
			
		||||
#endif /* __ONEWIRE_TEMP_SENSORS_H__ */
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
#define PINMASK(pin) ((0x3) << (pin * 2))
 | 
			
		||||
#define SETAF(PORT,PIN,AF)  PORT->AFR[(PIN < 8 ? 0 : 1)] |= AF << ((PIN < 8 ? PIN : (PIN - 8)) * 4)
 | 
			
		||||
#define ANALOG(pin)  (0x03 << (pin * 2))
 | 
			
		||||
#define OTYP_OPENDRAIN(pin) (0x1U << (pin))
 | 
			
		||||
 | 
			
		||||
#define BITMASK_TO_BITNO(x) (x&0x1?0:x&0x2?1:x&0x4?2:x&0x8?3: \
 | 
			
		||||
		 x&0x10?4:x&0x20?5:x&0x40?6:x&0x80?7: \
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user