добавлена функция быстрого конфигурирования вывода
This commit is contained in:
parent
f314eccaff
commit
19042298a0
@ -19,6 +19,7 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "pins_arduino.h"
|
#include "pins_arduino.h"
|
||||||
#include "mik32_hal_gpio.h"
|
#include "mik32_hal_gpio.h"
|
||||||
|
#include "wiring_LL.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -66,6 +67,26 @@ void pinMode(uint32_t PinNumber, uint32_t PinMode)
|
|||||||
additionalPinsInit(PinNumber);
|
additionalPinsInit(PinNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fastPinMode(uint32_t PinNumber, uint32_t PinMode)
|
||||||
|
{
|
||||||
|
GPIO_TypeDef* port = digitalPinToPort(PinNumber);
|
||||||
|
HAL_PinsTypeDef pinMask = digitalPinToBitMask(PinNumber);
|
||||||
|
// set direction
|
||||||
|
if (PinMode == OUTPUT)
|
||||||
|
GPIO_OUTPUT_MODE_PIN(port, pinMask);
|
||||||
|
else
|
||||||
|
GPIO_INPUT_MODE_PIN(port, pinMask);
|
||||||
|
|
||||||
|
// set pullup
|
||||||
|
if (PinMode == INPUT_PULLUP)
|
||||||
|
{
|
||||||
|
uint8_t pos = PIN_MASK_TO_PIN_NUMBER(pinMask);
|
||||||
|
if (port == GPIO_0) PIN_SET_PAD_CONFIG(PORT_0_PUPD, pos, HAL_GPIO_PULL_UP);
|
||||||
|
else if (port == GPIO_1) PIN_SET_PAD_CONFIG(PORT_1_PUPD, pos, HAL_GPIO_PULL_UP);
|
||||||
|
else PIN_SET_PAD_CONFIG(PORT_2_PUPD, pos, HAL_GPIO_PULL_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write pin
|
// write pin
|
||||||
void digitalWrite(uint32_t PinNumber, uint32_t Val)
|
void digitalWrite(uint32_t PinNumber, uint32_t Val)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user