/** * Shift Register library * * Author: Jan Dvořák z Vozerovic * E-mail: dvorkaman@gmail.com * Web: dvorkaman.asp2.cz * Created: 2014 */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ #ifndef __dvorkaman_shiftRegister_base_h__ #define __dvorkaman_shiftRegister_base_h__ /* DEFINES */ #define SHIFT_REGISTER_STORAGE_BITS 8 #define SHIFT_REGISTER_CLOCK_PULSE 24 // ns (for 74 HTC 595) - min 22 at 4.5V #define SHIFT_REGISTER_DATA_SETUP 16 // ns (for 74 HTC 595) - min 15 at 4.5V #define SHIFT_REGISTER_STORAGE_PULSE 24 // ns (for 74 HTC 595) - min 22 at 4.5V #define SHIFT_REGISTER_STORAGE_PULSE_SETUP 24 // ns (for 74 HTC 595) - min 22 at 4.5V /* STRUCTURES */ typedef struct { GPIO_TypeDef* gpio; uint16_t clockPin; uint16_t dataPin; uint16_t storagePin; uint8_t bits; uint8_t clockPulse; // ns uint8_t dataSetup; // ns uint8_t storagePulseSetup; // ns uint8_t storagePulse; // ns } libShiftRegister; /* HEADERS */ void shiftRegister_initialize(libShiftRegister* shiftRegister, GPIO_TypeDef* gpio, uint16_t clockPin, uint16_t dataPin, uint16_t storagePin); void shiftRegister_initializeBits(libShiftRegister* shiftRegister, GPIO_TypeDef* gpio, uint16_t clockPin, uint16_t dataPin, uint16_t storagePin, uint8_t bits); void shiftRegister_initializeFull(libShiftRegister* shiftRegister, GPIO_TypeDef* gpio, uint16_t clockPin, uint16_t dataPin, uint16_t storagePin, uint8_t bits, uint8_t clockPulse, uint8_t dataSetup, uint8_t storagePulse, uint8_t storagePulseSetup); void shiftRegister_write(libShiftRegister* shiftRegister, uint16_t value); #endif