Components and supplies
Jumper wires (generic)
Resistor 220 ohm
Arduino UNO
LED (generic)
Development Kit Accessory, Jumper Wire Kit
Breadboard (generic)
Shift Register- Parallel to Serial
Apps and platforms
arduino IDE
Project description
Code
ez_SIPO8_lib keyword file
c_cpp
ez_SIPO8_lib keywords
1# 2# Ron D Bentley, Stafford, UK 3# April 2021 4# SIPO8 v1-00 5# 6# This example and code is in the public domain and 7# may be used without restriction and without warranty 8# 9 10# class 11SIPO8 KEYWORD1 12 13# macros... 14pins_per_SIPO LITERAL1 15create_bank_failure LITERAL1 16pin_read_failure LITERAL1 17pin_invert_failure LITERAL1 18pin_set_failure LITERAL1 19bank_not_found LITERAL1 20SIPO_not_found LITERAL1 21timer0 LITERAL1 22timer1 LITERAL1 23timer2 LITERAL1 24timer3 LITERAL1 25timer4 LITERAL1 26timer5 LITERAL1 27timer6 LITERAL1 28timer7 LITERAL1 29elapsed LITERAL1 30not_elapsed LITERAL1 31active LITERAL1 32not_active LITERAL1 33 34# user accessible variables... 35max_pins KEYWORD2 36num_active_pins KEYWORD2 37num_pin_status_bytes KEYWORD2 38num_banks KEYWORD2 39max_SIPOs KEYWORD2 40bank_SIPO_count KEYWORD2 41max_timers KEYWORD2 42bank_data_pin KEYWORD2 43bank_clock_pin KEYWORD2 44bank_latch_pin KEYWORD2 45bank_num_SIPOs KEYWORD2 46bank_low_pin KEYWORD2 47bank_high_pin KEYWORD2 48SIPO_banks KEYWORD2 49pin_status_bytes KEYWORD2 50timer_status KEYWORD2 51start_time KEYWORD2 52timers KEYWORD2 53 54# functions... 55create_bank KEYWORD2 56set_all_array_pins KEYWORD2 57invert_all_array_pins KEYWORD2 58set_array_pin KEYWORD2 59invert_array_pin KEYWORD2 60read_array_pin KEYWORD2 61set_banks KEYWORD2 62set_banks KEYWORD2 63set_bank KEYWORD2 64invert_banks KEYWORD2 65invert_banks KEYWORD2 66invert_bank KEYWORD2 67set_bank_SIPO KEYWORD2 68invert_bank_SIPO KEYWORD2 69read_bank_SIPO KEYWORD2 70set_bank_pin KEYWORD2 71invert_bank_pin KEYWORD2 72read_bank_pin KEYWORD2 73get_bank_from_pin KEYWORD2 74num_pins_in_bank KEYWORD2 75xfer_banks KEYWORD2 76xfer_banks KEYWORD2 77xfer_bank KEYWORD2 78xfer_array KEYWORD2 79print_pin_statuses KEYWORD2 80print_SIPO_data KEYWORD2 81SIPO8_start_timer KEYWORD2 82SIPO8_stop_timer KEYWORD2 83SIPO8_timer_elapsed KEYWORD2 84 85# private variables 86_max_pins KEYWORD2 87_num_active_pins KEYWORD2 88 _num_pin_status_bytes KEYWORD2 89_max_SIPOs KEYWORD2 90 _bank_SIPO_count KEYWORD2 91_next_bank KEYWORD2 92_max_timers KEYWORD2 93 94# private functions... 95SIPO_lib_exit KEYWORD2 96shift_out_bank KEYWORD2 97
ez_SIPO8_lib .cpp file
c_cpp
ez_SIPO8_lib library functions
1/* 2 Ron D Bentley, Stafford, UK 3 April 2021 4 SIPO8 v1-00 5 6 Serial/Parallel IC (SIPO) library supporting banking of multiple SIPOs 7 of same/different bit sizes. 8 Supports maximum of up to 255 8bit SIPOs (2040 individual output pins) 9 and up to 255 indivual timers. 10 11 This example and code is in the public domain and 12 may be used without restriction and without warranty. 13 14*/ 15 16 17#include <Arduino.h> 18#include <ez_SIPO8_lib.h> 19 20// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21// This function will be called when the class is initiated. 22// The parameter is the maximum number of SIPOs that will be configured 23// in the sketch. 24// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25SIPO8::SIPO8(uint8_t max_SIPO_ICs, uint8_t Max_timers ) { 26 // Setup the SIPO_banks control data struture sized for the maximum number of 27 // SIPO banks that could be defined 28 SIPO_banks = (SIPO_control *) malloc(sizeof(SIPO_control) * max_SIPO_ICs); 29 if (SIPO_banks == NULL) { 30 SIPO_lib_exit(0); 31 } 32 // Determine how may pin_status_bytes of 'pins_per_SIPO' bit length are 33 // needed to map the number of bank SIPOs defined 34 _max_pins = max_SIPO_ICs * pins_per_SIPO; 35 max_pins = _max_pins; 36 _num_pin_status_bytes = max_SIPO_ICs; 37 num_pin_status_bytes = _num_pin_status_bytes; 38 pin_status_bytes = (uint8_t *) malloc(sizeof(pin_status_bytes) * _num_pin_status_bytes); // 1 byte per 8-bit SIPO 39 if (pin_status_bytes == NULL) { 40 SIPO_lib_exit(1); 41 } 42 // clear down pin_status_bytes to LOW (0) 43 for (uint8_t pin_status_byte = 0; pin_status_byte < _num_pin_status_bytes; pin_status_byte++) { 44 pin_status_bytes[pin_status_byte] = 0; 45 } 46 // create timer struct(ure) of required size 47 timers = (timer_control *) malloc(sizeof(timer_control) * Max_timers); 48 if (timers == NULL) { 49 SIPO_lib_exit(2); 50 } 51 _max_timers = Max_timers; 52 max_timers = Max_timers; 53 // initialise other working variables, private and user accessible 54 for (uint8_t timer = 0; timer < max_timers; timer++) { 55 timers[timer].timer_status = not_active; 56 timers[timer].start_time = 0; // elapsed time 57 } 58 _num_active_pins = 0; // no pins yet declared 59 num_active_pins = 0; 60 _max_SIPOs = max_SIPO_ICs; 61 max_SIPOs = _max_SIPOs; 62 _bank_SIPO_count = 0; 63 bank_SIPO_count = 0; 64 _next_bank = 0; 65 num_banks = 0; 66} 67 68// 69// General error reporting routine with termination 70// 71void SIPO8::SIPO_lib_exit(uint8_t reason) { 72 Serial.begin(9600); 73 switch (reason) { 74 case 0: 75 Serial.println(F("Exit:out of memory for setup-SIPO banks")); 76 break; 77 case 1: 78 Serial.println(F("Exit:out of memory for setup-status bytes")); 79 break; 80 case 2: 81 Serial.println(F("Exit:out of memory for setup-timers")); 82 break; 83 default: 84 Serial.println(F("Exit:unspecified")); 85 break; 86 } 87 Serial.flush(); 88 exit(reason); 89} 90 91// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92// The function will try to create a bank of SIPOs if possible. The create process 93// will fail if the more SIPOs for a bank are requested than remain unallocated. 94// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95int SIPO8::create_bank(uint8_t data_pin, uint8_t clock_pin, uint8_t latch_pin, 96 uint8_t num_SIPOs) { 97 if (_bank_SIPO_count + num_SIPOs <= _max_SIPOs && num_SIPOs > 0) { 98 // still enough free SIPOs available to assign to a new bank 99 pinMode(data_pin, OUTPUT); 100 digitalWrite(data_pin, LOW); 101 pinMode(clock_pin, OUTPUT); 102 digitalWrite(clock_pin, LOW); 103 pinMode(latch_pin, OUTPUT); 104 digitalWrite(latch_pin, LOW); 105 SIPO_banks[_next_bank].bank_data_pin = data_pin; 106 SIPO_banks[_next_bank].bank_clock_pin = clock_pin; 107 SIPO_banks[_next_bank].bank_latch_pin = latch_pin; 108 SIPO_banks[_next_bank].bank_num_SIPOs = num_SIPOs; 109 SIPO_banks[_next_bank].bank_low_pin = _num_active_pins; 110 uint16_t num_pins_this_bank = num_SIPOs * pins_per_SIPO; 111 SIPO_banks[_next_bank].bank_high_pin = _num_active_pins + num_pins_this_bank - 1;// inclusive pin numbers 112 _num_active_pins = _num_active_pins + num_pins_this_bank; 113 num_active_pins = _num_active_pins; 114 _bank_SIPO_count = _bank_SIPO_count + num_SIPOs; 115 bank_SIPO_count = _bank_SIPO_count; 116 _next_bank++; // next bank struct(ure) entry 117 num_banks = _next_bank; // user accessible number of banks defined 118 return _next_bank - 1; // return the bank number of this bank in the SIPOs struct(ure) 119 } 120 return create_bank_failure; // cannot provide number of SIPOs asked for, for this bank request 121} 122 123// 124// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 125// Function will set the entire array of pins to the given status value. Note that 126// this function operates on an entire array basis rather than bank by bank. 127// The parameter pin_status should be HIGH or LOW 128// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 129void SIPO8::set_all_array_pins(bool pin_status) { 130 uint8_t mask = pin_status * 255; // either 0 (all pins set low), or 255 (all pins set high) 131 for (uint8_t pin_status_byte = 0; pin_status_byte < _num_pin_status_bytes; pin_status_byte++) { 132 pin_status_bytes[pin_status_byte] = mask; 133 } 134} 135 136// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 137// Function will invert the status of each pin the the array. Note that 138// this function operates on an entire array basis rather than bank by bank. 139// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 140void SIPO8::invert_all_array_pins() { 141 for (uint8_t pin_status_byte = 0; pin_status_byte < _num_pin_status_bytes; pin_status_byte++) { 142 pin_status_bytes[pin_status_byte] = ~pin_status_bytes[pin_status_byte]; 143 } 144} 145 146// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 147// Function sets the given pin (absolute pin reference) to the given status value. 148// The success or otherwise of the process may be tested by the calling code using 149// the return function value. 150// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 151int SIPO8::set_array_pin(uint16_t pin, bool pin_status) { 152 if (pin < _num_active_pins) { 153 // pin is in the defined pin range 154 uint8_t pin_status_byte = pin / pins_per_SIPO; 155 uint8_t pin_bit = pin % pins_per_SIPO; 156 bitWrite(pin_status_bytes[pin_status_byte], pin_bit, pin_status); 157 return pin; 158 } 159 return pin_set_failure; 160} 161 162// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 163// Function inverts the existing pin status. Note that pin is given as an absolute 164// pin reference. 165// The success or otherwise of the process may be tested by the calling code using 166// the return function value. 167// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 168int SIPO8::invert_array_pin(uint16_t pin) { 169 if (pin < _num_active_pins) { 170 // pin is in the defined pin range 171 uint8_t pin_status_byte = pin / pins_per_SIPO; 172 uint8_t pin_bit = pin % pins_per_SIPO; 173 bool inverted_status = !bitRead(pin_status_bytes[pin_status_byte], pin_bit); 174 bitWrite(pin_status_bytes[pin_status_byte], 175 pin_bit, 176 inverted_status); 177 return inverted_status; // high or low status 178 } 179 return pin_invert_failure; 180} 181 182// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 183// Funcion will read the status value of the specified pin and return to the calling 184// code. Note that pin is given as an absolute pin reference. 185// The success or otherwise of the process may be tested by the calling code using 186// the return function value. 187// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 188int SIPO8::read_array_pin(uint16_t pin) { 189 if (pin < _num_active_pins) { 190 // pin is in the defined pin range 191 uint8_t pin_status_byte = pin / pins_per_SIPO; 192 uint8_t pin_bit = pin % pins_per_SIPO; 193 return bitRead(pin_status_bytes[pin_status_byte], pin_bit); // high or low status 194 } 195 return pin_read_failure; 196} 197 198// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 199// Function is equivalent to the set_all_array_pins function and is prvided as an 200// alternative choice. 201// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 202void SIPO8::set_banks(bool pin_status) { 203 set_all_array_pins(pin_status); 204} 205 206// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 207// Function will set every pin in each bank, from_bank - to_bank, to the 208// specified pin status. 209// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 210void SIPO8::set_banks(uint8_t from_bank, uint8_t to_bank, bool pin_status) { 211 if (from_bank <= to_bank && to_bank < _next_bank) { 212 for (uint8_t bank = from_bank; bank <= to_bank; bank++) { 213 set_bank(bank, pin_status); 214 } 215 } 216} 217 218// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 219// Function will set every pin in given bank to the specified pin status. 220// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 221void SIPO8::set_bank(uint8_t bank, bool pin_status) { 222 if (bank < _next_bank) { 223 // start with the first pin of the first SIPO in the bank 224 uint16_t first_pin = SIPO_banks[bank].bank_low_pin; // first pin in this bank 225 uint8_t mask = pin_status * 255; // either 0 (all pins set low), or 255 (all pins set high) 226 // determine the first pin status byte for the first pin in the bank 227 uint8_t pin_status_byte = first_pin / pins_per_SIPO; 228 // now deal with each SIPO declared in the bank, setting the 229 // associated pin status bytes accordingly 230 for (uint8_t SIPO = 0; SIPO < SIPO_banks[bank].bank_num_SIPOs; SIPO++) { 231 pin_status_bytes[pin_status_byte + SIPO] = mask; // reset all pin bits 232 } 233 } 234} 235 236// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 237// Function is equivalent to the invert_all_array_pins function and is prvided as an 238// alternative choice. 239// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 240void SIPO8::invert_banks() { 241 invert_all_array_pins(); 242} 243 244// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 245// Function will invert the existing pin status of every pin in the specified banks. 246// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 247void SIPO8::invert_banks(uint8_t from_bank, uint8_t to_bank) { 248 if (from_bank <= to_bank && to_bank < _next_bank) { 249 for (uint8_t bank = from_bank; bank <= to_bank; bank++) { 250 invert_bank(bank); 251 } 252 } 253} 254 255// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 256// Function will invert the existing pin status of every pin in the specified bank. 257// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 258void SIPO8::invert_bank(uint8_t bank) { 259 if (bank < _next_bank) { 260 // start with the first pin of the first SIPO in the bank 261 uint16_t first_pin = SIPO_banks[bank].bank_low_pin; // first pin in this bank 262 // determine the first pin status byte for the first pin in the bank 263 uint8_t pin_status_byte = first_pin / pins_per_SIPO; 264 // now deal with each SIPO declared in the bank, setting the 265 // associated pin status bytes accordingly 266 for (uint8_t SIPO = 0; SIPO < SIPO_banks[bank].bank_num_SIPOs; SIPO++) { 267 pin_status_bytes[pin_status_byte + SIPO] = 268 ~pin_status_bytes[pin_status_byte + SIPO]; // invert the status byte bits 269 } 270 } 271} 272 273// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 274// Function for setting specific pin within a given bank. 275// Note that these functions operate relative to the pins defined 276// in a bank - set_bank_pin, invert_bank_pin, read_bank_pin. 277// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 278int SIPO8::set_bank_pin(uint8_t bank, uint8_t pin, bool pin_status) { 279 if (bank < _next_bank) { 280 pin = pin + SIPO_banks[bank].bank_low_pin; // absolute pin number in the array 281 return set_array_pin(pin, pin_status); // returns failure or the absolute pin muber if successful 282 } 283 return pin_set_failure; 284} 285 286// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 287// Function for inverting specific existing pin status within a given bank. 288// Note that these functions operate relative to the pins defined 289// in a bank - set_bank_pin, invert_bank_pin, read_bank_pin. 290// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 291int SIPO8::invert_bank_pin(uint8_t bank, uint8_t pin) { 292 if (bank < _next_bank) { 293 pin = pin + SIPO_banks[bank].bank_low_pin; // absolute pin number in the array 294 return invert_array_pin(pin); // returns failure or the new status of the pin if successful 295 } 296 return pin_invert_failure; 297} 298 299// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 300// Function will read the given pin's status and return its value to the calling code. 301// Note that these functions operate relative to the pins defined 302// in a bank - set_bank_pin, invert_bank_pin, read_bank_pin. 303// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 304int SIPO8::read_bank_pin(uint8_t bank, uint8_t pin) { 305 if (bank < _next_bank) { 306 pin = pin + SIPO_banks[bank].bank_low_pin; // absolute pin number in the array 307 return read_array_pin(pin); // returns failure or the pin status if successful 308 } 309 return pin_read_failure; 310} 311 312// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 313// Function will set the given bank SIPO (8bits) to the secified value 314// Note that this functions operate relative to the SIPOs/pins defined 315// in a bank. 316// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 317int SIPO8::set_bank_SIPO(uint8_t bank, uint8_t SIPO_num, uint8_t SIPO_value) { 318 if (bank < _next_bank) { 319 // bank is valid 320 uint8_t SIPOs_this_bank = SIPO_banks[bank].bank_num_SIPOs; 321 if (SIPO_num < SIPOs_this_bank) { 322 // specified SIPO number is valid for this bank 323 // now determine the pin_staus_byte entry for the SIPO 324 uint8_t status_byte = SIPO_banks[bank].bank_low_pin / pins_per_SIPO;// first status byte for this bank 325 status_byte = status_byte + SIPO_num; // actual status byte to be set 326 pin_status_bytes[status_byte] = SIPO_value;// set required status byte 327 return status_byte; 328 } 329 return SIPO_not_found; 330 } 331 return bank_not_found; 332} 333 334// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 335// Function will invert the current contents of the given bank SIPO (8bits) to the 336// secified value. 337// Note that this functions operate relative to the SIPOs/pins defined 338// in a bank. 339// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 340int SIPO8::invert_bank_SIPO(uint8_t bank, uint8_t SIPO_num) { 341 if (bank < _next_bank) { 342 // bank is valid 343 uint8_t SIPOs_this_bank = SIPO_banks[bank].bank_num_SIPOs; 344 if (SIPO_num < SIPOs_this_bank) { 345 // specified SIPO number is valid for this bank 346 // now determine the pin_staus_byte entry for the SIPO 347 uint8_t status_byte = SIPO_banks[bank].bank_low_pin / pins_per_SIPO;// first status byte for this bank 348 status_byte = status_byte + SIPO_num; // actual status byte to be inverted 349 pin_status_bytes[status_byte] = ~pin_status_bytes[status_byte]; // invert current contents 350 return status_byte; 351 } 352 return SIPO_not_found; 353 } 354 return bank_not_found; 355} 356 357// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 358// Function will read the current contents of the given bank SIPO (8bits) and return 359// the 8bit status value for the SIPO. 360// Note that this functions operate relative to the SIPOs/pins defined 361// in a bank. 362// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 363int SIPO8::read_bank_SIPO(uint8_t bank, uint8_t SIPO_num) { 364 if (bank < _next_bank) { 365 // bank is valid 366 uint8_t SIPOs_this_bank = SIPO_banks[bank].bank_num_SIPOs; 367 if (SIPO_num < SIPOs_this_bank) { 368 // specified SIPO number is valid for this bank 369 // now determine the pin_staus_byte entry for the SIPO 370 uint8_t status_byte = SIPO_banks[bank].bank_low_pin / pins_per_SIPO;// first status byte for this bank 371 status_byte = status_byte + SIPO_num; // actual status byte to be read 372 return pin_status_bytes[status_byte]; 373 } 374 return SIPO_not_found; 375 } 376 return bank_not_found; 377} 378 379// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 380// Given an absolute array pin number, the function determines which 381// bank it resides within and returns the bank number. 382// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 383int SIPO8::get_bank_from_pin(uint16_t pin) { 384 if (pin < _num_active_pins) { 385 for (uint8_t bank = 0; bank < _next_bank; bank++) { 386 if (SIPO_banks[bank].bank_low_pin <= pin && 387 pin <= SIPO_banks[bank].bank_high_pin)return bank; 388 } 389 } 390 return bank_not_found; 391} 392 393// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 394// Determines the number of pins in the given bank 395// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 396int SIPO8::num_pins_in_bank(uint8_t bank) { 397 if (bank < _next_bank) { 398 // valid bank, so return number of pins in this bank 399 return SIPO_banks[bank].bank_num_SIPOs * pins_per_SIPO; 400 } 401 return bank_not_found; 402} 403 404 405// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 406// Selective transfer of array pin satuses based on bank transfers, 407// rather than the entire array of banks. 408// Transfers specified banks' pin statuses to the hardware SIPOs, 409// starting with from_bank and continuing to to_bank. 410// The direction of transfer is determined by the msb_or_lsb parameter 411// which must be either LSBFIRST or MSBFIRST. 412// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 413void SIPO8::xfer_banks(uint8_t from_bank, uint8_t to_bank, bool msb_or_lsb) { 414 if (from_bank <= to_bank && to_bank < _next_bank) { 415 // examine each bank in turn and deal with as many SIPOs as 416 // are configured in each bank 417 for (uint8_t bank = from_bank; bank <= to_bank; bank++) { 418 uint16_t low_pin = SIPO_banks[bank].bank_low_pin; // start pin number for this bank 419 uint16_t high_pin = SIPO_banks[bank].bank_high_pin; // end inclusive pin number for this bank 420 uint8_t latch_pin = SIPO_banks[bank].bank_latch_pin; 421 uint8_t clock_pin = SIPO_banks[bank].bank_clock_pin; 422 uint8_t data_pin = SIPO_banks[bank].bank_data_pin; 423 uint8_t num_SIPOs_this_bank = SIPO_banks[bank].bank_num_SIPOs; 424 uint8_t SIPO_first_status_byte = SIPO_banks[bank].bank_low_pin / pins_per_SIPO; 425 uint8_t SIPO_last_status_byte = SIPO_banks[bank].bank_high_pin / pins_per_SIPO; 426 uint8_t SIPO_status_byte = 0; 427 digitalWrite(latch_pin, LOW); // tell IC data transfer to start 428 for (uint8_t SIPO = 0; SIPO < num_SIPOs_this_bank; SIPO++) { 429 if (msb_or_lsb == LSBFIRST) { 430 SIPO_status_byte = SIPO_first_status_byte + SIPO; 431 } else { 432 SIPO_status_byte = SIPO_last_status_byte - SIPO; 433 } 434 shift_out_bank(data_pin, clock_pin, pin_status_bytes[SIPO_status_byte], msb_or_lsb); 435 } 436 digitalWrite(latch_pin, HIGH); // tell IC data transfer is finished 437 } 438 } 439} 440 441// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 442// Equivalent to xfer_array, and transfers all array pin statuses to the 443// the hardware SIPOs. Provided as an alternative method. 444// The direction of transfer is determined by the msb_or_lsb parameter 445// which must be either LSBFIRST or MSBFIRST. 446// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 447void SIPO8::xfer_banks(bool msb_or_lsb) { 448 if (_next_bank > 0) { 449 xfer_banks(0, _next_bank - 1, msb_or_lsb); 450 } 451} 452 453// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 454// Specific transfer of the given bank pin statuses to the bank's associated 455// hardware SIPOs. The direction of transfer is determined by the msb_or_lsb 456// parameter which must be either LSBFIRST or MSBFIRST. 457// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 458void SIPO8::xfer_bank(uint8_t bank, bool msb_or_lsb) { 459 if (_next_bank > 0) { 460 xfer_banks(bank, bank, msb_or_lsb); 461 } 462} 463 464// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 465// Transfers all array pin statuses to the hardware SIPOs. 466// The direction of transfer is determined by the msb_or_lsb parameter 467// which must be either LSBFIRST or MSBFIRST. 468// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 469void SIPO8::xfer_array(bool msb_or_lsb) { 470 xfer_banks(msb_or_lsb); 471} 472 473// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 474// Based on the standard Arduino shiftout function. 475// Moves out the given set of pin statuses, status_bits, to the specified SIPO. 476// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 477void SIPO8::shift_out_bank(uint8_t data_pin, uint8_t clock_pin, uint8_t status_bits, bool msb_or_lsb) 478{ // Shuffle each bit of the val parameter (0 or 1) one bit left 479 // until all bits written out. 480 for (uint8_t i = 0; i < pins_per_SIPO; i++) { 481 if (msb_or_lsb == LSBFIRST) { 482 digitalWrite(data_pin, !!(status_bits & (1 << i))); 483 } 484 else 485 { 486 digitalWrite(data_pin, !!(status_bits & (1 << (7 - i)))); 487 } 488 digitalWrite(clock_pin, HIGH); 489 digitalWrite(clock_pin, LOW); 490 } 491} 492 493// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 494// Function is provided to assist end user to provide debug data during development. 495// Prints all active pin status bytes, in bit form, starting with pin 0 and 496// progressing to the last active end pin defined. 497// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 498void SIPO8::print_pin_statuses() { 499 if (_next_bank > 0) { 500 Serial.println(F("\ 501Active pin array, pin statuses:")); 502 // there is at least 1 bank 503 uint8_t SIPO_count = 0; 504 for (uint8_t bank = 0; bank < _next_bank; bank++) { 505 Serial.print(F("Bank ")); 506 if (bank < 10)Serial.print(F(" ")); 507 Serial.print(bank); 508 Serial.print(F(": MS")); 509 uint8_t start_byte = SIPO_count; 510 uint8_t last_byte = start_byte + SIPO_banks[bank].bank_num_SIPOs - 1; 511 SIPO_count = SIPO_count + SIPO_banks[bank].bank_num_SIPOs; 512 for (int16_t next_byte = last_byte; next_byte >= start_byte; next_byte--) { 513 uint8_t SIPO_status = pin_status_bytes[next_byte]; 514 for (int pos = 7; pos >= 0; pos--) { 515 uint8_t pin_status = bitRead(SIPO_status, pos); 516 Serial.print(pin_status); 517 } 518 } 519 Serial.println(F("LS")); 520 } 521 } else { 522 Serial.println(F("\ 523No banks defined")); 524 } 525 Serial.flush(); 526} 527 528// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 529// Function is provided to assist end user to display debug data during development. 530// Prints all setup data as a confirmation that the end user has correctly configured 531// all key data. 532// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 533void SIPO8::print_SIPO_data() { 534 Serial.println(F("\ 535SIPO global values:")); 536 Serial.print(F("pins_per_SIPO = ")); 537 Serial.println(pins_per_SIPO); 538 Serial.print(F("max_SIPOs = ")); 539 Serial.println(_max_SIPOs); 540 Serial.print(F("bank_SIPO_count = ")); 541 Serial.println(_bank_SIPO_count); 542 Serial.print(F("num_active_pins = ")); 543 Serial.println(_num_active_pins); 544 Serial.print(F("num_pin_status_bytes = ")); 545 Serial.println(_num_pin_status_bytes); 546 Serial.print(F("next_free bank = ")); 547 if (_bank_SIPO_count < _max_SIPOs) { 548 Serial.print(_next_bank); 549 Serial.println(); 550 } else { 551 Serial.println(F(" all SIPOs used")); 552 } 553 Serial.print("Number timers = "); 554 Serial.println(_max_timers); 555 Serial.println(F("\ 556Bank data:")); 557 for (uint8_t bank = 0; bank < _next_bank; bank++) { 558 // still SIPOs available to assign to a new bank 559 Serial.print(F("bank = ")); 560 Serial.println(bank); 561 Serial.print(F(" num SIPOs =\ ")); 562 Serial.println(SIPO_banks[bank].bank_num_SIPOs); 563 Serial.print(F(" latch_pin =\ ")); 564 Serial.print(SIPO_banks[bank].bank_latch_pin); 565 Serial.print(F(" clock_pin =\ ")); 566 Serial.print(SIPO_banks[bank].bank_clock_pin); 567 Serial.print(F(" data_pin =\ ")); 568 Serial.println(SIPO_banks[bank].bank_data_pin); 569 Serial.print(F(" low_pin =\ ")); 570 Serial.print(SIPO_banks[bank].bank_low_pin); 571 Serial.print(F(" high_pin =\ ")); 572 Serial.println(SIPO_banks[bank].bank_high_pin); 573 } 574 Serial.flush(); 575} 576 577// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 578// Function sets the given timer as active and records the start time. 579// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 580void SIPO8::SIPO8_start_timer(uint8_t timer) { 581 if (timer < _max_timers) { 582 timers[timer].timer_status = active; 583 timers[timer].start_time = millis(); 584 } 585} 586 587// 588// Function cancels the given timer. 589// 590void SIPO8::SIPO8_stop_timer(uint8_t timer) { 591 if (timer < _max_timers) { 592 timers[timer].timer_status = not_active; 593 } 594} 595 596// 597// Function determines if the time has elapsed for the given timer, if active. 598// 599bool SIPO8::SIPO8_timer_elapsed(uint8_t timer, uint32_t elapsed_time) { 600 if (timer < _max_timers) { 601 if (timers[timer].timer_status == active) { 602 if (millis() - timers[timer].start_time >= elapsed_time) { 603 timers[timer].timer_status = not_active; // mark this timer no longer active 604 return elapsed; 605 } 606 } 607 } 608 return not_elapsed; 609}
ez_SIPO8_lib .h file
c_cpp
ez_SIPO8_lib header file
1/* 2 Ron D Bentley, Stafford, UK 3 April 2021 4 SIPO8 v1-00 5 6 Serial/Parallel IC (SIPO) library supporting banking of multiple SIPOs 7 of same/different bit sizes. 8 Supports maximum of up to 255 8bit SIPOs (2040 individual output pins) 9 and up to 255 indivual timers. 10 11 This example and code is in the public domain and 12 may be used without restriction and without warranty. 13 14*/ 15 16#ifndef SIPO8_h 17#define SIPO8_h 18 19#include <Arduino.h> // always include this lib otherwise wont compile! 20 21class SIPO8 22{ 23 public: 24 25 26#define pins_per_SIPO 8 // global 'set in stone' macro for a base SIPO unit 27 28 // failure macros... 29#define create_bank_failure -1 30#define pin_read_failure -1 31#define pin_invert_failure -1 32#define pin_set_failure -1 33#define bank_not_found -1 34#define SIPO_not_found -2 35 36 // timer macros... 37#define timer0 0 38#define timer1 1 39#define timer2 2 40#define timer3 3 41#define timer4 4 42#define timer5 5 43#define timer6 6 44#define timer7 7 45#define elapsed true 46#define not_elapsed !elapsed 47#define active true 48#define not_active !active 49 50 uint16_t max_pins = 0; // user accessible params 51 uint16_t num_active_pins = 0; // ... 52 uint8_t num_pin_status_bytes = 0; // ... 53 uint8_t num_banks = 0; // ... 54 uint8_t max_SIPOs = 0; // ... 55 uint8_t bank_SIPO_count = 0; // ... 56 uint8_t max_timers = 0; // ... 57 58 struct SIPO_control { 59 uint8_t bank_data_pin; 60 uint8_t bank_clock_pin; 61 uint8_t bank_latch_pin; 62 uint8_t bank_num_SIPOs; 63 uint16_t bank_low_pin; 64 uint16_t bank_high_pin; 65 }*SIPO_banks; 66 67 uint8_t * pin_status_bytes; // records current status of each pin 68 69 // timer control struct(ure) 70 struct timer_control { 71 bool timer_status; // records status of a timer - active or not active 72 uint32_t start_time; // records the millis time when a timer is started 73 } *timers; 74 75 // ******* function declarations.... 76 77 SIPO8(uint8_t, uint8_t); // constructor function called when class is initiated 78 79 int create_bank(uint8_t, uint8_t, uint8_t, uint8_t); 80 void set_all_array_pins(bool); 81 void invert_all_array_pins(); 82 int set_array_pin(uint16_t, bool); 83 int invert_array_pin(uint16_t); 84 int read_array_pin(uint16_t); 85 86 void set_banks(uint8_t, uint8_t, bool); 87 void set_banks(bool); 88 void set_bank(uint8_t, bool); 89 void invert_banks(); 90 void invert_banks(uint8_t, uint8_t); 91 void invert_bank(uint8_t); 92 93 int set_bank_SIPO(uint8_t, uint8_t, uint8_t); 94 int invert_bank_SIPO(uint8_t, uint8_t); 95 int read_bank_SIPO(uint8_t, uint8_t); 96 97 int set_bank_pin(uint8_t, uint8_t, bool); 98 int invert_bank_pin(uint8_t, uint8_t); 99 int read_bank_pin(uint8_t, uint8_t); 100 101 int get_bank_from_pin(uint16_t); 102 int num_pins_in_bank(uint8_t); 103 104 void xfer_banks(uint8_t, uint8_t, bool); 105 void xfer_banks(bool); 106 void xfer_bank(uint8_t, bool); 107 void xfer_array(bool); 108 109 void print_pin_statuses(); 110 void print_SIPO_data(); 111 112 void SIPO8_start_timer(uint8_t); 113 void SIPO8_stop_timer(uint8_t); 114 bool SIPO8_timer_elapsed(uint8_t, uint32_t); 115 116 // ****** private declarations..... 117 private: 118 uint16_t _max_pins = 0; 119 uint16_t _num_active_pins = 0; 120 uint8_t _num_pin_status_bytes = 0; 121 uint8_t _max_SIPOs = 0; 122 uint8_t _bank_SIPO_count = 0; 123 uint8_t _next_bank = 0; 124 uint8_t _max_timers = 0; 125 126 void SIPO_lib_exit(uint8_t); 127 void shift_out_bank(uint8_t, uint8_t, uint8_t, bool); 128 129 130 131}; 132 133#endif
ez_SIPO8_lib .h file
c_cpp
ez_SIPO8_lib header file
1/* 2 Ron D Bentley, Stafford, UK 3 April 2021 4 SIPO8 v1-00 5 6 Serial/Parallel IC (SIPO) library supporting banking of multiple SIPOs 7 of same/different bit sizes. 8 Supports maximum of up to 255 8bit SIPOs (2040 individual output pins) 9 and up to 255 indivual timers. 10 11 This example and code is in the public domain and 12 may be used without restriction and without warranty. 13 14*/ 15 16#ifndef SIPO8_h 17#define SIPO8_h 18 19#include <Arduino.h> // always include this lib otherwise wont compile! 20 21class SIPO8 22{ 23 public: 24 25 26#define pins_per_SIPO 8 // global 'set in stone' macro for a base SIPO unit 27 28 // failure macros... 29#define create_bank_failure -1 30#define pin_read_failure -1 31#define pin_invert_failure -1 32#define pin_set_failure -1 33#define bank_not_found -1 34#define SIPO_not_found -2 35 36 // timer macros... 37#define timer0 0 38#define timer1 1 39#define timer2 2 40#define timer3 3 41#define timer4 4 42#define timer5 5 43#define timer6 6 44#define timer7 7 45#define elapsed true 46#define not_elapsed !elapsed 47#define active true 48#define not_active !active 49 50 uint16_t max_pins = 0; // user accessible params 51 uint16_t num_active_pins = 0; // ... 52 uint8_t num_pin_status_bytes = 0; // ... 53 uint8_t num_banks = 0; // ... 54 uint8_t max_SIPOs = 0; // ... 55 uint8_t bank_SIPO_count = 0; // ... 56 uint8_t max_timers = 0; // ... 57 58 struct SIPO_control { 59 uint8_t bank_data_pin; 60 uint8_t bank_clock_pin; 61 uint8_t bank_latch_pin; 62 uint8_t bank_num_SIPOs; 63 uint16_t bank_low_pin; 64 uint16_t bank_high_pin; 65 }*SIPO_banks; 66 67 uint8_t * pin_status_bytes; // records current status of each pin 68 69 // timer control struct(ure) 70 struct timer_control { 71 bool timer_status; // records status of a timer - active or not active 72 uint32_t start_time; // records the millis time when a timer is started 73 } *timers; 74 75 // ******* function declarations.... 76 77 SIPO8(uint8_t, uint8_t); // constructor function called when class is initiated 78 79 int create_bank(uint8_t, uint8_t, uint8_t, uint8_t); 80 void set_all_array_pins(bool); 81 void invert_all_array_pins(); 82 int set_array_pin(uint16_t, bool); 83 int invert_array_pin(uint16_t); 84 int read_array_pin(uint16_t); 85 86 void set_banks(uint8_t, uint8_t, bool); 87 void set_banks(bool); 88 void set_bank(uint8_t, bool); 89 void invert_banks(); 90 void invert_banks(uint8_t, uint8_t); 91 void invert_bank(uint8_t); 92 93 int set_bank_SIPO(uint8_t, uint8_t, uint8_t); 94 int invert_bank_SIPO(uint8_t, uint8_t); 95 int read_bank_SIPO(uint8_t, uint8_t); 96 97 int set_bank_pin(uint8_t, uint8_t, bool); 98 int invert_bank_pin(uint8_t, uint8_t); 99 int read_bank_pin(uint8_t, uint8_t); 100 101 int get_bank_from_pin(uint16_t); 102 int num_pins_in_bank(uint8_t); 103 104 void xfer_banks(uint8_t, uint8_t, bool); 105 void xfer_banks(bool); 106 void xfer_bank(uint8_t, bool); 107 void xfer_array(bool); 108 109 void print_pin_statuses(); 110 void print_SIPO_data(); 111 112 void SIPO8_start_timer(uint8_t); 113 void SIPO8_stop_timer(uint8_t); 114 bool SIPO8_timer_elapsed(uint8_t, uint32_t); 115 116 // ****** private declarations..... 117 private: 118 uint16_t _max_pins = 0; 119 uint16_t _num_active_pins = 0; 120 uint8_t _num_pin_status_bytes = 0; 121 uint8_t _max_SIPOs = 0; 122 uint8_t _bank_SIPO_count = 0; 123 uint8_t _next_bank = 0; 124 uint8_t _max_timers = 0; 125 126 void SIPO_lib_exit(uint8_t); 127 void shift_out_bank(uint8_t, uint8_t, uint8_t, bool); 128 129 130 131}; 132 133#endif
ez_SIPO8_lib keyword file
c_cpp
ez_SIPO8_lib keywords
1# 2# Ron D Bentley, Stafford, UK 3# April 2021 4# SIPO8 v1-00 5# 6# 7 This example and code is in the public domain and 8# may be used without 9 restriction and without warranty 10# 11 12# class 13SIPO8 KEYWORD1 14 15# 16 macros... 17pins_per_SIPO LITERAL1 18create_bank_failure LITERAL1 19pin_read_failure LITERAL1 20 21pin_invert_failure LITERAL1 22pin_set_failure LITERAL1 23bank_not_found LITERAL1 24 25SIPO_not_found LITERAL1 26timer0 LITERAL1 27timer1 LITERAL1 28timer2 LITERAL1 29 30timer3 LITERAL1 31timer4 LITERAL1 32timer5 LITERAL1 33timer6 LITERAL1 34 35timer7 LITERAL1 36elapsed LITERAL1 37not_elapsed LITERAL1 38active LITERAL1 39 40not_active LITERAL1 41 42# user accessible variables... 43max_pins KEYWORD2 44num_active_pins KEYWORD2 45num_pin_status_bytes KEYWORD2 46num_banks KEYWORD2 47max_SIPOs KEYWORD2 48bank_SIPO_count KEYWORD2 49max_timers KEYWORD2 50bank_data_pin KEYWORD2 51bank_clock_pin KEYWORD2 52bank_latch_pin KEYWORD2 53bank_num_SIPOs KEYWORD2 54bank_low_pin KEYWORD2 55bank_high_pin KEYWORD2 56SIPO_banks KEYWORD2 57pin_status_bytes KEYWORD2 58timer_status KEYWORD2 59start_time KEYWORD2 60timers KEYWORD2 61 62# 63 functions... 64create_bank KEYWORD2 65set_all_array_pins KEYWORD2 66invert_all_array_pins KEYWORD2 67set_array_pin KEYWORD2 68invert_array_pin KEYWORD2 69read_array_pin KEYWORD2 70set_banks KEYWORD2 71set_banks KEYWORD2 72set_bank KEYWORD2 73invert_banks KEYWORD2 74invert_banks KEYWORD2 75invert_bank KEYWORD2 76set_bank_SIPO KEYWORD2 77invert_bank_SIPO KEYWORD2 78read_bank_SIPO KEYWORD2 79set_bank_pin KEYWORD2 80invert_bank_pin KEYWORD2 81read_bank_pin KEYWORD2 82get_bank_from_pin KEYWORD2 83num_pins_in_bank KEYWORD2 84xfer_banks KEYWORD2 85xfer_banks KEYWORD2 86xfer_bank KEYWORD2 87xfer_array KEYWORD2 88print_pin_statuses KEYWORD2 89print_SIPO_data KEYWORD2 90SIPO8_start_timer KEYWORD2 91SIPO8_stop_timer KEYWORD2 92SIPO8_timer_elapsed KEYWORD2 93 94# 95 private variables 96_max_pins KEYWORD2 97_num_active_pins KEYWORD2 98 _num_pin_status_bytes KEYWORD2 99_max_SIPOs KEYWORD2 100 101 _bank_SIPO_count KEYWORD2 102_next_bank KEYWORD2 103_max_timers KEYWORD2 104 105# 106 private functions... 107SIPO_lib_exit KEYWORD2 108shift_out_bank KEYWORD2 109
Downloadable files
Cascaded SIPO Shift Registers, wiring diagram
Used by Tutorial 4, Cascading SIPOs
Cascaded SIPO Shift Registers, wiring diagram
Cascaded SIPO Shift Registers, wiring diagram
Used by Tutorial 4, Cascading SIPOs
Cascaded SIPO Shift Registers, wiring diagram
Single SIPO Shift Register, wiring diagram
Used throughout the tutorials
Single SIPO Shift Register, wiring diagram
Single SIPO Shift Register, wiring diagram
Used throughout the tutorials
Single SIPO Shift Register, wiring diagram
Comments
Only logged in users can leave comments