hw functions for the SOLID slow control
Dependents: S_SCTRL_e_test SPItest sscm
S_SCTRL_SM1_hwfunct.cpp@3:39671ee1347d, 2014-09-15 (annotated)
- Committer:
- wbeaumont
- Date:
- Mon Sep 15 14:55:03 2014 +0000
- Revision:
- 3:39671ee1347d
- Parent:
- 1:af78e316f889
- Child:
- 6:24e981a63851
sync not tested
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbeaumont | 0:8d755a0f3ab3 | 1 | /* hardware functions */ |
wbeaumont | 0:8d755a0f3ab3 | 2 | #include "mbed.h" |
wbeaumont | 0:8d755a0f3ab3 | 3 | #include "S_SCTRL_SM1_PinDef.h" |
wbeaumont | 1:af78e316f889 | 4 | #include "S_SCTRL_SM1_hwfunct.h" |
wbeaumont | 1:af78e316f889 | 5 | |
wbeaumont | 0:8d755a0f3ab3 | 6 | |
wbeaumont | 3:39671ee1347d | 7 | #define HW_LIB_SRC_VERSION "1.00" |
wbeaumont | 3:39671ee1347d | 8 | |
wbeaumont | 3:39671ee1347d | 9 | #define MAXLIBVERCHAR 100 // max char for lib version |
wbeaumont | 0:8d755a0f3ab3 | 10 | |
wbeaumont | 1:af78e316f889 | 11 | void assignports(HWlines *hwlines ){ |
wbeaumont | 0:8d755a0f3ab3 | 12 | |
wbeaumont | 0:8d755a0f3ab3 | 13 | /// devices |
wbeaumont | 0:8d755a0f3ab3 | 14 | // SPI BI pins |
wbeaumont | 1:af78e316f889 | 15 | hwlines->msio[0] = new DigitalInOut(ADC_STIO); |
wbeaumont | 1:af78e316f889 | 16 | hwlines->sclk[0] = new DigitalOut(SCLK); |
wbeaumont | 1:af78e316f889 | 17 | hwlines->direction[0] = new DigitalOut(DIRECTION); |
wbeaumont | 1:af78e316f889 | 18 | hwlines->stio_mo[0] = new DigitalOut(STIO_MO); |
wbeaumont | 3:39671ee1347d | 19 | hwlines->csb1[0] = new DigitalOut(ADC1_CSN); |
wbeaumont | 3:39671ee1347d | 20 | hwlines->csb2[0] = new DigitalOut(ADC2_CSN); |
wbeaumont | 0:8d755a0f3ab3 | 21 | |
wbeaumont | 0:8d755a0f3ab3 | 22 | |
wbeaumont | 0:8d755a0f3ab3 | 23 | |
wbeaumont | 0:8d755a0f3ab3 | 24 | // SPI pins |
wbeaumont | 1:af78e316f889 | 25 | hwlines->mosi[0] = new DigitalOut(MOSI); |
wbeaumont | 1:af78e316f889 | 26 | hwlines->miso[0] = new DigitalIn(MISO); |
wbeaumont | 0:8d755a0f3ab3 | 27 | |
wbeaumont | 1:af78e316f889 | 28 | hwlines->t_cs[0] = new DigitalOut(TEMP_CSN); |
wbeaumont | 1:af78e316f889 | 29 | hwlines->tc_cs1[0] = new DigitalOut(TEMP_CABLE_CSN1); |
wbeaumont | 1:af78e316f889 | 30 | hwlines->tc_cs2[0] = new DigitalOut(TEMP_CABLE_CSN2); |
wbeaumont | 1:af78e316f889 | 31 | hwlines->dac_cs[0] = new DigitalOut(DAC_DCEN); |
wbeaumont | 1:af78e316f889 | 32 | hwlines->dac_rst[0] = new DigitalOut(DAC_RSTN); |
wbeaumont | 0:8d755a0f3ab3 | 33 | |
wbeaumont | 0:8d755a0f3ab3 | 34 | |
wbeaumont | 0:8d755a0f3ab3 | 35 | |
wbeaumont | 0:8d755a0f3ab3 | 36 | |
wbeaumont | 0:8d755a0f3ab3 | 37 | // devices |
wbeaumont | 0:8d755a0f3ab3 | 38 | // SPI BI pins |
wbeaumont | 1:af78e316f889 | 39 | hwlines->msio[1] = new DigitalInOut(ADC_2_STIO); |
wbeaumont | 1:af78e316f889 | 40 | hwlines->sclk[1] = new DigitalOut(SCLK_2); |
wbeaumont | 1:af78e316f889 | 41 | hwlines->direction[1] = new DigitalOut(DIRECTION2); |
wbeaumont | 1:af78e316f889 | 42 | hwlines->stio_mo[1] = new DigitalOut(STIO2_MO); |
wbeaumont | 3:39671ee1347d | 43 | hwlines->csb1[1] = new DigitalOut(ADC1_2_CSN); |
wbeaumont | 3:39671ee1347d | 44 | hwlines->csb2[1] = new DigitalOut(ADC2_2_CSN); |
wbeaumont | 0:8d755a0f3ab3 | 45 | |
wbeaumont | 0:8d755a0f3ab3 | 46 | // SPI pins |
wbeaumont | 1:af78e316f889 | 47 | hwlines->mosi[1] = new DigitalOut(MOSI_2); |
wbeaumont | 1:af78e316f889 | 48 | hwlines->miso[1] = new DigitalIn(MISO_2); |
wbeaumont | 0:8d755a0f3ab3 | 49 | |
wbeaumont | 1:af78e316f889 | 50 | hwlines->t_cs[1] = new DigitalOut(TEMP_2_CSN); |
wbeaumont | 1:af78e316f889 | 51 | hwlines->tc_cs1[1] = new DigitalOut(TEMP_2_CABLE_CSN1); |
wbeaumont | 1:af78e316f889 | 52 | hwlines->tc_cs2[1] = new DigitalOut(TEMP_2_CABLE_CSN2); |
wbeaumont | 1:af78e316f889 | 53 | hwlines->dac_cs[1] = new DigitalOut(DAC_2_DCEN); |
wbeaumont | 1:af78e316f889 | 54 | hwlines->dac_rst[1] = new DigitalOut(DAC_2_RSTN); |
wbeaumont | 0:8d755a0f3ab3 | 55 | |
wbeaumont | 0:8d755a0f3ab3 | 56 | |
wbeaumont | 0:8d755a0f3ab3 | 57 | //cal |
wbeaumont | 1:af78e316f889 | 58 | hwlines->cal13[0] = new DigitalOut(CAL_TRIG_1AND3); |
wbeaumont | 1:af78e316f889 | 59 | hwlines->cal24[0] = new DigitalOut(CAL_TRIG_2AND4); |
wbeaumont | 1:af78e316f889 | 60 | hwlines->calint[0] = new DigitalOut(SEL_CAL_INT); |
wbeaumont | 1:af78e316f889 | 61 | hwlines->cal13[1] = new DigitalOut(CAL_TRIG_1AND3); |
wbeaumont | 1:af78e316f889 | 62 | hwlines->cal24[1] = new DigitalOut(CAL_TRIG_2AND4); |
wbeaumont | 1:af78e316f889 | 63 | hwlines->calint[1] = new DigitalOut(SEL_2_CAL_INT); |
wbeaumont | 0:8d755a0f3ab3 | 64 | |
wbeaumont | 1:af78e316f889 | 65 | hwlines->calext = new DigitalOut(SEL_CAL_EXT); |
wbeaumont | 1:af78e316f889 | 66 | hwlines->calgenext = new DigitalOut(GEN_EXT_CAL); |
wbeaumont | 0:8d755a0f3ab3 | 67 | |
wbeaumont | 1:af78e316f889 | 68 | hwlines->ledred = new DigitalOut(LEDRED); |
wbeaumont | 1:af78e316f889 | 69 | hwlines->ledgreen = new DigitalOut(LEDGREEN); |
wbeaumont | 0:8d755a0f3ab3 | 70 | |
wbeaumont | 1:af78e316f889 | 71 | hwlines->ain[0] = new AnalogIn(ADC1); |
wbeaumont | 1:af78e316f889 | 72 | hwlines->ain[1] = new AnalogIn(ADC2); |
wbeaumont | 0:8d755a0f3ab3 | 73 | |
wbeaumont | 0:8d755a0f3ab3 | 74 | |
wbeaumont | 0:8d755a0f3ab3 | 75 | } |
wbeaumont | 0:8d755a0f3ab3 | 76 | |
wbeaumont | 0:8d755a0f3ab3 | 77 | |
wbeaumont | 0:8d755a0f3ab3 | 78 | |
wbeaumont | 0:8d755a0f3ab3 | 79 | // select intern or extern cal 0 = intern, 1 is extern |
wbeaumont | 1:af78e316f889 | 80 | void setcalsource( int external, HWlines hwl) { |
wbeaumont | 0:8d755a0f3ab3 | 81 | *(hwl.calext)=0; *(hwl.calint[0])=0; *(hwl.calint[0])=0; //disable all |
wbeaumont | 0:8d755a0f3ab3 | 82 | if ( external==1 ) {*(hwl.calext)=1; } |
wbeaumont | 0:8d755a0f3ab3 | 83 | else {*(hwl.calint[0])=1; *(hwl.calint[0])=1; } |
wbeaumont | 0:8d755a0f3ab3 | 84 | |
wbeaumont | 0:8d755a0f3ab3 | 85 | |
wbeaumont | 0:8d755a0f3ab3 | 86 | } |
wbeaumont | 0:8d755a0f3ab3 | 87 | |
wbeaumont | 0:8d755a0f3ab3 | 88 | // set tje default , save values |
wbeaumont | 0:8d755a0f3ab3 | 89 | void setdefault(HWlines hwl ) { |
wbeaumont | 0:8d755a0f3ab3 | 90 | for ( int i=0;i<2;i++){ |
wbeaumont | 0:8d755a0f3ab3 | 91 | hwl.msio[i]->input(); |
wbeaumont | 0:8d755a0f3ab3 | 92 | *(hwl.direction[i])=LDIR_IN; |
wbeaumont | 1:af78e316f889 | 93 | *(hwl.stio_mo[i])=RDIR_IN; |
wbeaumont | 0:8d755a0f3ab3 | 94 | } |
wbeaumont | 1:af78e316f889 | 95 | setcalsource(0,hwl); //intern |
wbeaumont | 0:8d755a0f3ab3 | 96 | } |
wbeaumont | 0:8d755a0f3ab3 | 97 | |
wbeaumont | 3:39671ee1347d | 98 | char libversion[MAXLIBVERCHAR]={'e','m','p','t','y','\0'}; |
wbeaumont | 3:39671ee1347d | 99 | |
wbeaumont | 3:39671ee1347d | 100 | |
wbeaumont | 3:39671ee1347d | 101 | char* hwfunct_lib_version(){ |
wbeaumont | 3:39671ee1347d | 102 | sprintf(libversion,"hw lib versions src : %s header: %s ,date:%s %s \n\r",HW_LIB_SRC_VERSION,HW_LIB_HDR_VERSION , __DATE__,__TIME__); |
wbeaumont | 3:39671ee1347d | 103 | return libversion; |
wbeaumont | 3:39671ee1347d | 104 | |
wbeaumont | 3:39671ee1347d | 105 | } |