mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
98b38399df
Always enable the internal pull-up on the SCL line to always have a functional I2C bus. This may increase power consumption where an external pull up is present as well. But let's wait for a real world use case where this would help to extend battery life before making this configurable. This fixes https://github.com/RIOT-OS/RIOT/issues/19021
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/*
|
|
* Copyright (C) 2020 iosabi
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
* Public License v2.1. See the file LICENSE in the top level directory for more
|
|
* details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup cpu_qn908x
|
|
*
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief Flexcomm interface functions.
|
|
*
|
|
* The FLEXCOMM blocks can operate in different modes such as UART, SPI and I2C,
|
|
* but not all modules support all modes. These functions allow to initialize
|
|
* and configure the FLEXCOMM, as well as route back the ISRs to the
|
|
* corresponding module.
|
|
*
|
|
* @author iosabi <iosabi@protonmail.com>
|
|
*/
|
|
|
|
#ifndef FLEXCOMM_H
|
|
#define FLEXCOMM_H
|
|
|
|
#include <stdint.h>
|
|
#include "periph_cpu.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief Flexcomm PSELID values
|
|
*
|
|
* This value identifies the current function of a FLEXCOMM module.
|
|
*/
|
|
typedef enum {
|
|
FLEXCOMM_ID_UART = 1, /**< UART mode. */
|
|
FLEXCOMM_ID_SPI = 2, /**< SPI mode. */
|
|
FLEXCOMM_ID_I2C = 3, /**< I2C mode. */
|
|
} flexcom_pselid_t;
|
|
|
|
/**
|
|
* @brief Initialize a flexcomm module to operate as the selected mode.
|
|
*
|
|
* @returns -1 in case of error, otherwise returns the number of flexcomm
|
|
* instance initialized, such as 2 for FLEXCOMM2.
|
|
*/
|
|
int flexcomm_init(FLEXCOMM_Type *dev, flexcom_pselid_t mode);
|
|
|
|
/**
|
|
* @brief Obtain the flexcomm block number (0-based) from the address.
|
|
*
|
|
* For example, the flexcomm block number of FLEXCOMM2, the pointer to the
|
|
* FLEXCOMM_Type block is 2. If an invalid address is passed returns -1.
|
|
*/
|
|
int flexcomm_instance_from_addr(const FLEXCOMM_Type *dev);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* FLEXCOMM_H */
|
|
/** @} */
|