добавлена проверка - не превышает ли номер вывода из аргумента функции общее кол-во выводов
This commit is contained in:
1 parent
5b2e2eb1d5
commit
fbaa4b931a
11 files changed
+171
-96
No files matched your search
@@ -79,6 +79,12 @@ static void calcFrequencyParams(FrequencyParams_t* params, unsigned int newFrequ
|
||||
// start tone with frequency (in hertz) and duration (in milliseconds)
|
||||
void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
|
||||
{
|
||||
if ((pin>=pinCommonQty()))
|
||||
{
|
||||
ErrorMsgHandler("tone(): pin number exceeds the total number of pins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!timerIsOn) // if tone is not generated at the moment
|
||||
{
|
||||
// calculate the parameters necessary to ensure a given frequency if the frequency has changed
|
||||
@@ -123,6 +129,12 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
|
||||
// stop tone
|
||||
void noTone(uint8_t pin)
|
||||
{
|
||||
if ((pin>=pinCommonQty()))
|
||||
{
|
||||
ErrorMsgHandler("noTone(): pin number exceeds the total number of pins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (timerIsOn)
|
||||
{
|
||||
// pin to 0
|
||||
|
||||
@@ -170,7 +170,7 @@ It is recommended to turn off the timer in the following order:
|
||||
*/
|
||||
void analogWriteStop(uint32_t PinNumber)
|
||||
{
|
||||
if ((pwmIsInited > 0) && (digitalPinPwmIsOn(PinNumber)))
|
||||
if (digitalPinHasPWM(PinNumber) && (pwmIsInited > 0) && digitalPinPwmIsOn(PinNumber))
|
||||
{
|
||||
// load the timer address and channel number corresponding to the specified pin
|
||||
htimer32.Instance = pwmPinToTimer(PinNumber);
|
||||
|
||||
@@ -69,8 +69,15 @@ void pinMode(uint32_t PinNumber, uint32_t PinMode)
|
||||
|
||||
void fastPinMode(uint32_t PinNumber, uint32_t PinMode)
|
||||
{
|
||||
if ((PinNumber>=pinCommonQty()))
|
||||
{
|
||||
ErrorMsgHandler("fastPinMode(): pin number exceeds the total number of pins");
|
||||
return;
|
||||
}
|
||||
|
||||
GPIO_TypeDef* port = digitalPinToPort(PinNumber);
|
||||
HAL_PinsTypeDef pinMask = digitalPinToBitMask(PinNumber);
|
||||
|
||||
// set direction
|
||||
if (PinMode == OUTPUT)
|
||||
GPIO_OUTPUT_MODE_PIN(port, pinMask);
|
||||
|
||||
Reference in new issue
Block a user