hw functions for the SOLID slow control

Dependents:   S_SCTRL_e_test SPItest sscm

Committer:
wbeaumont
Date:
Sun Sep 07 18:55:47 2014 +0000
Revision:
4:a83242fe9d37
Parent:
1:af78e316f889
Child:
5:b527df9432c3
change names of adc cs lines

Who changed what in which revision?

UserRevisionLine numberNew 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 0:8d755a0f3ab3 7
wbeaumont 1:af78e316f889 8 void assignports(HWlines *hwlines ){
wbeaumont 0:8d755a0f3ab3 9
wbeaumont 0:8d755a0f3ab3 10 /// devices
wbeaumont 0:8d755a0f3ab3 11 // SPI BI pins
wbeaumont 1:af78e316f889 12 hwlines->msio[0] = new DigitalInOut(ADC_STIO);
wbeaumont 1:af78e316f889 13 hwlines->sclk[0] = new DigitalOut(SCLK);
wbeaumont 1:af78e316f889 14 hwlines->direction[0] = new DigitalOut(DIRECTION);
wbeaumont 1:af78e316f889 15 hwlines->stio_mo[0] = new DigitalOut(STIO_MO);
wbeaumont 4:a83242fe9d37 16 hwlines->csb1[0] = new DigitalOut(ADC1_CSN);
wbeaumont 4:a83242fe9d37 17 hwlines->csb2[0] = new DigitalOut(ADC2_CSN);
wbeaumont 0:8d755a0f3ab3 18
wbeaumont 0:8d755a0f3ab3 19
wbeaumont 0:8d755a0f3ab3 20
wbeaumont 0:8d755a0f3ab3 21 // SPI pins
wbeaumont 1:af78e316f889 22 hwlines->mosi[0] = new DigitalOut(MOSI);
wbeaumont 1:af78e316f889 23 hwlines->miso[0] = new DigitalIn(MISO);
wbeaumont 0:8d755a0f3ab3 24
wbeaumont 1:af78e316f889 25 hwlines->t_cs[0] = new DigitalOut(TEMP_CSN);
wbeaumont 1:af78e316f889 26 hwlines->tc_cs1[0] = new DigitalOut(TEMP_CABLE_CSN1);
wbeaumont 1:af78e316f889 27 hwlines->tc_cs2[0] = new DigitalOut(TEMP_CABLE_CSN2);
wbeaumont 1:af78e316f889 28 hwlines->dac_cs[0] = new DigitalOut(DAC_DCEN);
wbeaumont 1:af78e316f889 29 hwlines->dac_rst[0] = new DigitalOut(DAC_RSTN);
wbeaumont 0:8d755a0f3ab3 30
wbeaumont 0:8d755a0f3ab3 31
wbeaumont 0:8d755a0f3ab3 32
wbeaumont 0:8d755a0f3ab3 33
wbeaumont 0:8d755a0f3ab3 34 // devices
wbeaumont 0:8d755a0f3ab3 35 // SPI BI pins
wbeaumont 1:af78e316f889 36 hwlines->msio[1] = new DigitalInOut(ADC_2_STIO);
wbeaumont 1:af78e316f889 37 hwlines->sclk[1] = new DigitalOut(SCLK_2);
wbeaumont 1:af78e316f889 38 hwlines->direction[1] = new DigitalOut(DIRECTION2);
wbeaumont 1:af78e316f889 39 hwlines->stio_mo[1] = new DigitalOut(STIO2_MO);
wbeaumont 4:a83242fe9d37 40 hwlines->csb1[1] = new DigitalOut(ADC1_2_CSN);
wbeaumont 4:a83242fe9d37 41 hwlines->csb2[1] = new DigitalOut(ADC2_2_CSN);
wbeaumont 0:8d755a0f3ab3 42
wbeaumont 0:8d755a0f3ab3 43 // SPI pins
wbeaumont 1:af78e316f889 44 hwlines->mosi[1] = new DigitalOut(MOSI_2);
wbeaumont 1:af78e316f889 45 hwlines->miso[1] = new DigitalIn(MISO_2);
wbeaumont 0:8d755a0f3ab3 46
wbeaumont 1:af78e316f889 47 hwlines->t_cs[1] = new DigitalOut(TEMP_2_CSN);
wbeaumont 1:af78e316f889 48 hwlines->tc_cs1[1] = new DigitalOut(TEMP_2_CABLE_CSN1);
wbeaumont 1:af78e316f889 49 hwlines->tc_cs2[1] = new DigitalOut(TEMP_2_CABLE_CSN2);
wbeaumont 1:af78e316f889 50 hwlines->dac_cs[1] = new DigitalOut(DAC_2_DCEN);
wbeaumont 1:af78e316f889 51 hwlines->dac_rst[1] = new DigitalOut(DAC_2_RSTN);
wbeaumont 0:8d755a0f3ab3 52
wbeaumont 0:8d755a0f3ab3 53
wbeaumont 0:8d755a0f3ab3 54 //cal
wbeaumont 1:af78e316f889 55 hwlines->cal13[0] = new DigitalOut(CAL_TRIG_1AND3);
wbeaumont 1:af78e316f889 56 hwlines->cal24[0] = new DigitalOut(CAL_TRIG_2AND4);
wbeaumont 1:af78e316f889 57 hwlines->calint[0] = new DigitalOut(SEL_CAL_INT);
wbeaumont 1:af78e316f889 58 hwlines->cal13[1] = new DigitalOut(CAL_TRIG_1AND3);
wbeaumont 1:af78e316f889 59 hwlines->cal24[1] = new DigitalOut(CAL_TRIG_2AND4);
wbeaumont 1:af78e316f889 60 hwlines->calint[1] = new DigitalOut(SEL_2_CAL_INT);
wbeaumont 0:8d755a0f3ab3 61
wbeaumont 1:af78e316f889 62 hwlines->calext = new DigitalOut(SEL_CAL_EXT);
wbeaumont 1:af78e316f889 63 hwlines->calgenext = new DigitalOut(GEN_EXT_CAL);
wbeaumont 0:8d755a0f3ab3 64
wbeaumont 1:af78e316f889 65 hwlines->ledred = new DigitalOut(LEDRED);
wbeaumont 1:af78e316f889 66 hwlines->ledgreen = new DigitalOut(LEDGREEN);
wbeaumont 0:8d755a0f3ab3 67
wbeaumont 1:af78e316f889 68 hwlines->ain[0] = new AnalogIn(ADC1);
wbeaumont 1:af78e316f889 69 hwlines->ain[1] = new AnalogIn(ADC2);
wbeaumont 0:8d755a0f3ab3 70
wbeaumont 0:8d755a0f3ab3 71
wbeaumont 0:8d755a0f3ab3 72 }
wbeaumont 0:8d755a0f3ab3 73
wbeaumont 0:8d755a0f3ab3 74
wbeaumont 0:8d755a0f3ab3 75
wbeaumont 0:8d755a0f3ab3 76 // select intern or extern cal 0 = intern, 1 is extern
wbeaumont 1:af78e316f889 77 void setcalsource( int external, HWlines hwl) {
wbeaumont 0:8d755a0f3ab3 78 *(hwl.calext)=0; *(hwl.calint[0])=0; *(hwl.calint[0])=0; //disable all
wbeaumont 0:8d755a0f3ab3 79 if ( external==1 ) {*(hwl.calext)=1; }
wbeaumont 0:8d755a0f3ab3 80 else {*(hwl.calint[0])=1; *(hwl.calint[0])=1; }
wbeaumont 0:8d755a0f3ab3 81
wbeaumont 0:8d755a0f3ab3 82
wbeaumont 0:8d755a0f3ab3 83 }
wbeaumont 0:8d755a0f3ab3 84
wbeaumont 0:8d755a0f3ab3 85 // set tje default , save values
wbeaumont 0:8d755a0f3ab3 86 void setdefault(HWlines hwl ) {
wbeaumont 0:8d755a0f3ab3 87 for ( int i=0;i<2;i++){
wbeaumont 0:8d755a0f3ab3 88 hwl.msio[i]->input();
wbeaumont 0:8d755a0f3ab3 89 *(hwl.direction[i])=LDIR_IN;
wbeaumont 1:af78e316f889 90 *(hwl.stio_mo[i])=RDIR_IN;
wbeaumont 0:8d755a0f3ab3 91 }
wbeaumont 1:af78e316f889 92 setcalsource(0,hwl); //intern
wbeaumont 0:8d755a0f3ab3 93 }
wbeaumont 0:8d755a0f3ab3 94