used in the Elixys Radiochemistry system for selecting subsystems
Revision 0:9ba7adee8fce, committed 2013-10-30
- Comitter:
- henryeherman
- Date:
- Wed Oct 30 07:03:11 2013 +0000
- Commit message:
- chip select using the 595 shift register, allowing endless number of periphreals
Changed in this revision
ChipSelectArray.cpp | Show annotated file Show diff for this revision Revisions of this file |
ChipSelectArray.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 9ba7adee8fce ChipSelectArray.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ChipSelectArray.cpp Wed Oct 30 07:03:11 2013 +0000 @@ -0,0 +1,140 @@ +#include "ChipSelectArray.h" + +DigitalOut cssck(P1_20); +DigitalOut csdat(P1_24); +DigitalOut cslatch(P1_21); +DigitalOut csclr(P1_22); +DigitalOut csoe(P1_25); +ShiftRegister shiftreg(cssck, csdat, cslatch, csclr, csoe); + +void unselect() { + shiftreg.write((unsigned int)NONECS, 32); +} + +void selectvalve0(void) { + shiftreg.write((unsigned int)VALVCS0, 32); +} + +void selectvalve1(void) { + shiftreg.write((unsigned int)VALVCS1, 32); +} + +void selectvalve2(void) { + shiftreg.write((unsigned int)VALVCS2, 32); +} + +void selecttc0() { + shiftreg.write((unsigned int)THERMCOUPLECS0, 32); +} + +void selecttc1() { + shiftreg.write((unsigned int)THERMCOUPLECS1, 32); +} + +void selecttc2() { + shiftreg.write((unsigned int)THERMCOUPLECS2, 32); +} + +void selecttc3(void) { + shiftreg.write((unsigned int)THERMCOUPLECS3, 32); +} + +void selecttc4() { + shiftreg.write((unsigned int)THERMCOUPLECS4, 32); +} + +void selecttc5() { + shiftreg.write((unsigned int)THERMCOUPLECS5, 32); +} + +void selecttc6() { + shiftreg.write((unsigned int)THERMCOUPLECS6, 32); +} + +void selecttc7() { + shiftreg.write((unsigned int)THERMCOUPLECS7, 32); +} + +void selecttc8() { + shiftreg.write((unsigned int)THERMCOUPLECS8, 32); +} + +void selectheater(void) { + shiftreg.write((unsigned int)HEATERCS, 32); +} + +void selectliq(void) { + shiftreg.write((unsigned int)LIQUIDSENSORCS, 32); +} + +void selectpos(void) { + shiftreg.write((unsigned int)POSITIONSENSORCS, 32); +} + +void selectsmcadc(void) { + shiftreg.write((unsigned int)SMCADCCS, 32); +} + +void selectsmddac(void) { + shiftreg.write((unsigned int)SMCDACCS, 32); +} + +void selectrad0(void) { + shiftreg.write((unsigned int)RADCS0, 32); +} + +void selectrad1(void) { + shiftreg.write((unsigned int)RADCS1, 32); +} + +void selectrad2(void) { + shiftreg.write((unsigned int)RADCS2, 32); +} + +void selectrad3(void) { + shiftreg.write((unsigned int)RADCS3, 32); +} + +void selectrad4(void) { + shiftreg.write((unsigned int)RADCS4, 32); +} + +void selectrad5(void) { + shiftreg.write((unsigned int)RADCS5, 32); +} + +void selectrad6(void) { + shiftreg.write((unsigned int)RADCS6, 32); +} + +void selectaux0(void) { + shiftreg.write((unsigned int)AUXCS0, 32); +} + +void selectaux1(void) { + shiftreg.write((unsigned int)AUXCS1, 32); +} + +void selectaux2(void) { + shiftreg.write((unsigned int)AUXCS2, 32); +} + +void selectaux3(void) { + shiftreg.write((unsigned int)AUXCS3, 32); +} + +void selectaux4(void) { + shiftreg.write((unsigned int)AUXCS4, 32); +} + +void selectaux5(void) { + shiftreg.write((unsigned int)AUXCS5, 32); +} + +void selectaux6(void) { + shiftreg.write((unsigned int)AUXCS6, 32); +} + +void selectaux7(void){ + shiftreg.write((unsigned int)AUXCS7, 32); +}
diff -r 000000000000 -r 9ba7adee8fce ChipSelectArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ChipSelectArray.h Wed Oct 30 07:03:11 2013 +0000 @@ -0,0 +1,76 @@ +#ifndef CHIPSELECT_H +#define CHIPSELECT_H +#include "mbed.h" +#include "ShiftRegister.h" + +#define FIRST2LAST(X) (31 - (X)) +#define VALVCS0 ~(1U << FIRST2LAST(0)) +#define VALVCS1 ~(1U << FIRST2LAST(1)) +#define VALVCS2 ~(1U << FIRST2LAST(2)) +#define THERMCOUPLECS0 ~(1U << FIRST2LAST(3)) +#define THERMCOUPLECS1 ~(1U << FIRST2LAST(4)) +#define THERMCOUPLECS2 ~(1U << FIRST2LAST(5)) +#define THERMCOUPLECS3 ~(1U << FIRST2LAST(6)) +#define THERMCOUPLECS4 ~(1U << FIRST2LAST(7)) +#define THERMCOUPLECS5 ~(1U << FIRST2LAST(8)) +#define THERMCOUPLECS6 ~(1U << FIRST2LAST(9)) +#define THERMCOUPLECS7 ~(1U << FIRST2LAST(10)) +#define THERMCOUPLECS8 ~(1U << FIRST2LAST(11)) +#define HEATERCS ~(1U << FIRST2LAST(12)) +#define LIQUIDSENSORCS ~(1U << FIRST2LAST(13)) +#define POSITIONSENSORCS ~(1U << FIRST2LAST(14)) +#define SMCADCCS ~(1U << FIRST2LAST(15)) +#define SMCDACCS ~(1U << FIRST2LAST(16)) +#define RADCS0 ~(1U << FIRST2LAST(17)) +#define RADCS1 ~(1U << FIRST2LAST(18)) +#define RADCS2 ~(1U << FIRST2LAST(19)) +#define RADCS3 ~(1U << FIRST2LAST(20)) +#define RADCS4 ~(1U << FIRST2LAST(21)) +#define RADCS5 ~(1U << FIRST2LAST(22)) +#define RADCS6 ~(1U << FIRST2LAST(23)) +#define AUXCS0 ~(1U << FIRST2LAST(24)) +#define AUXCS1 ~(1U << FIRST2LAST(25)) +#define AUXCS2 ~(1U << FIRST2LAST(26)) +#define AUXCS3 ~(1U << FIRST2LAST(27)) +#define AUXCS4 ~(1U << FIRST2LAST(28)) +#define AUXCS5 ~(1U << FIRST2LAST(29)) +#define AUXCS6 ~(1U << FIRST2LAST(30)) +#define AUXCS7 ~(1U << FIRST2LAST(31)) +#define NONECS ~(0x00000000) + + +void unselect(void); +void selectvalve0(void); +void selectvalve1(void); +void selectvalve2(void); +void selecttc0(void); +void selecttc1(void); +void selecttc2(void); +void selecttc3(void); +void selecttc4(void); +void selecttc5(void); +void selecttc6(void); +void selecttc7(void); +void selecttc8(void); +void selectheater(void); +void selectliq(void); +void selectpos(void); +void selectsmcadc(void); +void selectsmddac(void); +void selectrad0(void); +void selectrad1(void); +void selectrad2(void); +void selectrad3(void); +void selectrad4(void); +void selectrad5(void); +void selectrad6(void); +void selectaux0(void); +void selectaux1(void); +void selectaux2(void); +void selectaux3(void); +void selectaux4(void); +void selectaux5(void); +void selectaux6(void); +void selectaux7(void); + +#endif //CHIPSELECT_H \ No newline at end of file