sensor_pzem: fix USART GPIO definitions

This commit is contained in:
King Kévin 2020-02-17 14:52:16 +01:00
parent 41bd39f123
commit 6a0b0bf7d1
2 changed files with 11 additions and 11 deletions

View File

@ -12,10 +12,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** library to query measurements from peacefair PZEM-004 and PZEM-004T electricity meter (code)
* @file sensor_pzem.c
/** library to query measurements from peacefair PZEM-004 and PZEM-004T electricity meter
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016
* @date 2016-2020
* @note peripherals used: USART @ref sensor_pzem_usart, timer @ref sensor_pzem_timer
*/
@ -59,11 +59,11 @@ void sensor_pzem_setup(void)
{
/* enable USART I/O peripheral */
rcc_periph_clock_enable(RCC_AFIO); // enable pin alternate function (USART)
rcc_periph_clock_enable(USART_PORT_RCC(SENSOR_PZEM_USART)); // enable clock for USART port peripheral
rcc_periph_clock_enable(USART_RCC(SENSOR_PZEM_USART)); // enable clock for USART peripheral
gpio_set_mode(USART_PORT(SENSOR_PZEM_USART), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USART_PIN_TX(SENSOR_PZEM_USART)); // setup GPIO pin USART transmit
gpio_set_mode(USART_PORT(SENSOR_PZEM_USART), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, USART_PIN_RX(SENSOR_PZEM_USART)); // setup GPIO pin USART receive
gpio_set(USART_PORT(SENSOR_PZEM_USART), USART_PIN_RX(SENSOR_PZEM_USART)); // pull up to avoid noise when not connected
rcc_periph_clock_enable(RCC_USART(SENSOR_PZEM_USART)); // enable clock for USART peripheral
rcc_periph_clock_enable(RCC_USART_PORT(SENSOR_PZEM_USART)); // enable clock for USART port peripheral
gpio_set_mode(USART_TX_PORT(SENSOR_PZEM_USART), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USART_TX_PIN(SENSOR_PZEM_USART)); // setup GPIO pin USART transmit
gpio_set_mode(USART_RX_PORT(SENSOR_PZEM_USART), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, USART_RX_PIN(SENSOR_PZEM_USART)); // setup GPIO pin USART receive
gpio_set(USART_RX_PORT(SENSOR_PZEM_USART), USART_RX_PIN(SENSOR_PZEM_USART)); // pull up to avoid noise when not connected
/* setup USART parameters for electricity meter: 9600 8N1 */
usart_set_baudrate(USART(SENSOR_PZEM_USART), 9600); // the electricity meter uses a fixed baud rate of 9600 bps

View File

@ -12,10 +12,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** library to query measurements from peacefair PZEM-004 and PZEM-004T electricity meter (API)
* @file sensor_pzem.h
/** library to query measurements from peacefair PZEM-004 and PZEM-004T electricity meter
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016
* @date 2016-2020
* @note peripherals used: USART @ref sensor_pzem_usart, timer @ref sensor_pzem_timer
*/
#pragma once