/*! Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ" Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. \file V_DIO.h \brief Ìîäóëü äèñêðåòíûõ âõîäîâ/âûõîäîâ \author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru \version v 1.0 25/08/2017 \addtogroup @{*/ #ifndef V_DIO_H #define V_DIO_H #ifdef __cplusplus extern "C" { #endif // Ìàêðîñ óñòàíîâêè â '1' çàäàííîãî áèòà // var - öåëåâàß ïåðåìåííàß // index - èíäåêñ (ñìåùåíèå) óñòàíàâëèâàåìîãî áèòà #define SET_BIT(var, index) var |= (1 << index); // Ìàêðîñ ñáðîñà â '0' çàäàííîãî áèòà // var - öåëåâàß ïåðåìåííàß // index - èíäåêñ (ñìåùåíèå) î÷èùàåìîãî áèòà #define CLEAR_BIT(var, index) var &= (~(1 << index)); // Ìàêðîñ ïðîâåðêè íåíóëåâîãî ñîñòîßíèÿ çàäàííîãî áèòà // var - öåëåâàß ïåðåìåííàß // index - èíäåêñ (ñìåùåíèå) ïðîâåðßåìîãî áèòà #define BIT_IS_SET(var, index) ((var & (1 << index)) != 0) // Ìàêðîñ ïðîâåðêè íóëåâîãî ñîñòîßíèÿ çàäàííîãî áèòà // var - öåëåâàß ïåðåìåííàß // index - èíäåêñ (ñìåùåíèå) ïðîâåðßåìîãî áèòà #define BIT_IS_CLEAR(var, index) ((var & (1 << index)) == 0) // Äåôàéíèì äèñêðåòíûå âõîäû #ifdef HW_MOTORCONTROLBOARD #define D_IN1 ((GPIOA->DATA & (1 << 14)) == 0) // Âõîä 1 #else #define D_IN1 0 #endif // Äåôàéíèì äèñêðåòíûå âûõîäû #ifdef HW_MOTORCONTROLBOARD #define D_OUT1_ON GPIOA->DATAOUTSET = (1 << 15) #define D_OUT1_OFF GPIOA->DATAOUTCLR = (1 << 15) #else #define D_OUT1_ON #define D_OUT1_OFF #endif // Âåêòîð ñîñòîßíèß äèñêðåòíûõ âûõîäîâ extern volatile Uint8 output_vect; // Âåêòîð ñîñòîßíèß äèñêðåòíûõ âõîäîâ extern volatile Uint8 input_vect; void DIO_Init(); void DIO_slow_calc(); // âûçûâàòü â ôîíîâîé ïðîãðàììå void DIO_fast_calc(); // âûçûâàòü ñ ÷àñòîòîé 1êÃö èëè 10 êÃö #ifdef __cplusplus } #endif #endif /*@}*/