sn74x138.h (1394B)
1 /* Copyright 2022 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17 #pragma once 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 22 /** 23 * Driver for 74x138 3-to-8 decoder/demultiplexer with inverting outputs 24 * https://assets.nexperia.com/documents/data-sheet/74HC_HCT138.pdf 25 */ 26 27 /** 28 * Initialize the address and output enable pins. 29 */ 30 void sn74x138_init(void); 31 32 /** 33 * Set the enabled state. 34 * 35 * When enabled is true, pulls the E1 and E2 pins low, and the E3 pin high. 36 * 37 * \param enabled The enable state to set. 38 */ 39 void sn74x138_set_enabled(bool enabled); 40 41 /** 42 * Set the output pin address. 43 * 44 * The selected output pin will be pulled low, while the remaining output pins will be high. 45 * 46 * \param address The address to set, from 0 to 7. 47 */ 48 void sn74x138_set_addr(uint8_t address);