The library for Shift Register (ex. 74595).

Dependents:   888LEDCUBE_RGB 888LEDCUBE_RGB

Committer:
ztztno1
Date:
Wed Jul 22 13:36:52 2015 +0000
Revision:
0:9f0e9ea56740
new Repo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ztztno1 0:9f0e9ea56740 1 /*
ztztno1 0:9f0e9ea56740 2 The MIT License (MIT)
ztztno1 0:9f0e9ea56740 3
ztztno1 0:9f0e9ea56740 4 Copyright (c) 2015 雑学追究室ぐり
ztztno1 0:9f0e9ea56740 5
ztztno1 0:9f0e9ea56740 6 Permission is hereby granted, free of charge, to any person obtaining a copy
ztztno1 0:9f0e9ea56740 7 of this software and associated documentation files (the "Software"), to deal
ztztno1 0:9f0e9ea56740 8 in the Software without restriction, including without limitation the rights
ztztno1 0:9f0e9ea56740 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ztztno1 0:9f0e9ea56740 10 copies of the Software, and to permit persons to whom the Software is
ztztno1 0:9f0e9ea56740 11 furnished to do so, subject to the following conditions:
ztztno1 0:9f0e9ea56740 12
ztztno1 0:9f0e9ea56740 13 The above copyright notice and this permission notice shall be included in all
ztztno1 0:9f0e9ea56740 14 copies or substantial portions of the Software.
ztztno1 0:9f0e9ea56740 15
ztztno1 0:9f0e9ea56740 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ztztno1 0:9f0e9ea56740 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ztztno1 0:9f0e9ea56740 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ztztno1 0:9f0e9ea56740 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ztztno1 0:9f0e9ea56740 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ztztno1 0:9f0e9ea56740 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
ztztno1 0:9f0e9ea56740 22 SOFTWARE.
ztztno1 0:9f0e9ea56740 23 */
ztztno1 0:9f0e9ea56740 24
ztztno1 0:9f0e9ea56740 25 #include "SPIShiftReg.h"
ztztno1 0:9f0e9ea56740 26
ztztno1 0:9f0e9ea56740 27 SPIShiftReg::SPIShiftReg(PinName data, PinName sclk, PinName rck, int freq) : spi(data, NC, sclk) , _rck(rck){
ztztno1 0:9f0e9ea56740 28 spi.format(8, 0);
ztztno1 0:9f0e9ea56740 29 spi.frequency(freq);
ztztno1 0:9f0e9ea56740 30 _rck = 0;
ztztno1 0:9f0e9ea56740 31 }
ztztno1 0:9f0e9ea56740 32
ztztno1 0:9f0e9ea56740 33 void SPIShiftReg::write(char data[], int len){
ztztno1 0:9f0e9ea56740 34 for(int i = 0; i < len; i++){
ztztno1 0:9f0e9ea56740 35 spi.write(data[i]);
ztztno1 0:9f0e9ea56740 36 }
ztztno1 0:9f0e9ea56740 37 _rck = 1;
ztztno1 0:9f0e9ea56740 38 _rck = 0;
ztztno1 0:9f0e9ea56740 39 }
ztztno1 0:9f0e9ea56740 40