Sold slow control/

Dependents:   sscm

Fork of S_SCTRL_SMlib by wimbeaumont Project

Committer:
wbeaumont
Date:
Mon Sep 15 15:14:42 2014 +0000
Revision:
6:24e981a63851
Parent:
3:39671ee1347d
Parent:
5:b527df9432c3
Child:
7:cb139102ec05
sync changes

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 6:24e981a63851 7 #define HW_LIB_SRC_VERSION "1.01"
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 4:a83242fe9d37 19 hwlines->csb1[0] = new DigitalOut(ADC1_CSN);
wbeaumont 4:a83242fe9d37 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 4:a83242fe9d37 43 hwlines->csb1[1] = new DigitalOut(ADC1_2_CSN);
wbeaumont 4:a83242fe9d37 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 5:b527df9432c3 88 // set the 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 6:24e981a63851 98
wbeaumont 5:b527df9432c3 99 void set_bi_spi_mo(int masterout, DigitalInOut* msio, DigitalOut* ldir, DigitalOut* rdir){
wbeaumont 5:b527df9432c3 100 // default directions
wbeaumont 5:b527df9432c3 101 if( masterout == 0 ) { // master in
wbeaumont 5:b527df9432c3 102 msio->input();
wbeaumont 5:b527df9432c3 103 rdir->write(RDIR_IN);
wbeaumont 5:b527df9432c3 104 ldir->write(LDIR_IN);
wbeaumont 5:b527df9432c3 105
wbeaumont 5:b527df9432c3 106 }
wbeaumont 5:b527df9432c3 107 else { //master out
wbeaumont 5:b527df9432c3 108
wbeaumont 5:b527df9432c3 109 ldir->write(LDIR_OUT);
wbeaumont 5:b527df9432c3 110 msio->output();
wbeaumont 5:b527df9432c3 111 rdir->write(RDIR_OUT);
wbeaumont 5:b527df9432c3 112 }
wbeaumont 5:b527df9432c3 113 }
wbeaumont 5:b527df9432c3 114
wbeaumont 5:b527df9432c3 115
wbeaumont 6:24e981a63851 116
wbeaumont 6:24e981a63851 117
wbeaumont 5:b527df9432c3 118 // set the default , save values
wbeaumont 5:b527df9432c3 119 void setdefault(HWlines hwl ) {
wbeaumont 5:b527df9432c3 120 for ( int i=0;i<2;i++){
wbeaumont 5:b527df9432c3 121 hwl.msio[i]->input();
wbeaumont 5:b527df9432c3 122 *(hwl.direction[i])=LDIR_IN;
wbeaumont 5:b527df9432c3 123 *(hwl.stio_mo[i])=RDIR_IN;
wbeaumont 5:b527df9432c3 124 }
wbeaumont 5:b527df9432c3 125 setcalsource(0,hwl); //intern
wbeaumont 5:b527df9432c3 126 }
wbeaumont 0:8d755a0f3ab3 127
wbeaumont 3:39671ee1347d 128 char libversion[MAXLIBVERCHAR]={'e','m','p','t','y','\0'};
wbeaumont 3:39671ee1347d 129
wbeaumont 3:39671ee1347d 130
wbeaumont 3:39671ee1347d 131 char* hwfunct_lib_version(){
wbeaumont 3:39671ee1347d 132 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 133 return libversion;
wbeaumont 3:39671ee1347d 134
wbeaumont 6:24e981a63851 135 }
wbeaumont 6:24e981a63851 136
wbeaumont 6:24e981a63851 137