test
Dependencies: ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259
PerifConfig.cpp@3:d4b106bf3a32, 2020-08-08 (annotated)
- Committer:
- nikmaos
- Date:
- Sat Aug 08 18:32:53 2020 +0000
- Revision:
- 3:d4b106bf3a32
- Parent:
- 1:5d28312892aa
- Child:
- 4:d53895f65eb7
808
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vitlog | 1:5d28312892aa | 1 | #include "PerifConfig.h" |
vitlog | 1:5d28312892aa | 2 | #include <stdio.h> |
vitlog | 1:5d28312892aa | 3 | |
vitlog | 1:5d28312892aa | 4 | /*Переопределение имени пинов для платы ТЭД2*/ |
nikmaos | 3:d4b106bf3a32 | 5 | DigitalOut Cs(PD_2); |
vitlog | 1:5d28312892aa | 6 | DigitalOut En1(D15); |
vitlog | 1:5d28312892aa | 7 | |
vitlog | 1:5d28312892aa | 8 | DigitalOut Adr0(D5); |
vitlog | 1:5d28312892aa | 9 | DigitalOut Adr1(D6); |
vitlog | 1:5d28312892aa | 10 | DigitalOut Adr2(D7); |
vitlog | 1:5d28312892aa | 11 | |
nikmaos | 3:d4b106bf3a32 | 12 | DigitalOut ads1259_pin_Start(PG_2); |
nikmaos | 3:d4b106bf3a32 | 13 | DigitalOut ads1259_pin_CS(PD_2); |
nikmaos | 3:d4b106bf3a32 | 14 | DigitalIn ads1259_pin_Drdy(PG_3); |
nikmaos | 3:d4b106bf3a32 | 15 | |
nikmaos | 3:d4b106bf3a32 | 16 | |
nikmaos | 3:d4b106bf3a32 | 17 | DigitalOut Reset(PG_2); |
nikmaos | 3:d4b106bf3a32 | 18 | DigitalIn CrdyA(PG_3); |
nikmaos | 3:d4b106bf3a32 | 19 | |
vitlog | 1:5d28312892aa | 20 | |
nikmaos | 3:d4b106bf3a32 | 21 | /*Плата СБ-1*/ |
nikmaos | 3:d4b106bf3a32 | 22 | DigitalOut SB1_SWEN(PB_13); |
nikmaos | 3:d4b106bf3a32 | 23 | DigitalIn PosAr(PB_12); |
nikmaos | 3:d4b106bf3a32 | 24 | DigitalIn PosBr(PA_15); |
nikmaos | 3:d4b106bf3a32 | 25 | DigitalOut SB1_SHDN(PC_6); |
nikmaos | 3:d4b106bf3a32 | 26 | DigitalOut PosAw(PB_15); |
nikmaos | 3:d4b106bf3a32 | 27 | DigitalOut PosBw(PC_7); |
nikmaos | 3:d4b106bf3a32 | 28 | /*Конец*/ |
nikmaos | 3:d4b106bf3a32 | 29 | |
nikmaos | 3:d4b106bf3a32 | 30 | //выводы для костыльного SPI |
nikmaos | 3:d4b106bf3a32 | 31 | DigitalOut DOUT(PF_1); |
nikmaos | 3:d4b106bf3a32 | 32 | //DigitalIn MISO(D12); |
nikmaos | 3:d4b106bf3a32 | 33 | DigitalOut CLK(PF_2); |
vitlog | 1:5d28312892aa | 34 | /*Конец*/ |
vitlog | 1:5d28312892aa | 35 | |
vitlog | 1:5d28312892aa | 36 | //MOSI,MISO,SCK |
nikmaos | 3:d4b106bf3a32 | 37 | SPI TED2(PC_12, PC_11, PC_10); |
nikmaos | 3:d4b106bf3a32 | 38 | //SPI AD1248_SPI(PB_5,PB_4,PB_3); |
nikmaos | 3:d4b106bf3a32 | 39 | Serial UART(SERIAL_TX,SERIAL_RX,9600); |
nikmaos | 3:d4b106bf3a32 | 40 | extern PwmOut Pressure(D3); |
vitlog | 1:5d28312892aa | 41 | |
vitlog | 1:5d28312892aa | 42 | void UART_gets(char maxcount) |
vitlog | 1:5d28312892aa | 43 | /*Функция получения строки и записи её в глобальную переменную str[]*/ |
vitlog | 1:5d28312892aa | 44 | { |
vitlog | 1:5d28312892aa | 45 | int i=0; |
vitlog | 1:5d28312892aa | 46 | do |
vitlog | 1:5d28312892aa | 47 | { |
vitlog | 1:5d28312892aa | 48 | while (UART.readable()); //перед точкой с запятой цикл |
vitlog | 1:5d28312892aa | 49 | str[i++]=UART.getc(); |
vitlog | 1:5d28312892aa | 50 | } |
vitlog | 1:5d28312892aa | 51 | while ((str[i-2]!=0x0D)&&(str[i-1]!=0x0A)); |
vitlog | 1:5d28312892aa | 52 | for (i=i;i<maxcount;i++) |
vitlog | 1:5d28312892aa | 53 | { |
vitlog | 1:5d28312892aa | 54 | str[i]='\0'; |
vitlog | 1:5d28312892aa | 55 | } |
vitlog | 1:5d28312892aa | 56 | } |
vitlog | 1:5d28312892aa | 57 | |
vitlog | 1:5d28312892aa | 58 | |
vitlog | 1:5d28312892aa | 59 | |
vitlog | 1:5d28312892aa | 60 | void DebugString (unsigned char *sData,unsigned char sz) |
vitlog | 1:5d28312892aa | 61 | { |
vitlog | 1:5d28312892aa | 62 | /* |
vitlog | 1:5d28312892aa | 63 | int i; |
vitlog | 1:5d28312892aa | 64 | for (i=0;i<sz;i++) |
vitlog | 1:5d28312892aa | 65 | { |
vitlog | 1:5d28312892aa | 66 | if (sData[i]==0x00) //если пришёл символ конца строки то не отправляем что-либо |
vitlog | 1:5d28312892aa | 67 | { |
vitlog | 1:5d28312892aa | 68 | i=sz; |
vitlog | 1:5d28312892aa | 69 | } |
vitlog | 1:5d28312892aa | 70 | else UART1_Transmit(sData[i]); |
vitlog | 1:5d28312892aa | 71 | } |
vitlog | 1:5d28312892aa | 72 | */ |
vitlog | 1:5d28312892aa | 73 | } |
vitlog | 1:5d28312892aa | 74 | |
vitlog | 1:5d28312892aa | 75 | void SPI1_MasterInitMode(char mode) |
vitlog | 1:5d28312892aa | 76 | { |
vitlog | 1:5d28312892aa | 77 | TED2.format(8,mode); |
nikmaos | 3:d4b106bf3a32 | 78 | TED2.frequency(100000); |
vitlog | 1:5d28312892aa | 79 | } |
nikmaos | 3:d4b106bf3a32 | 80 | /*void SPI3_MasterInitMode(char mode) |
nikmaos | 3:d4b106bf3a32 | 81 | { |
nikmaos | 3:d4b106bf3a32 | 82 | AD1248_SPI.format(8,mode); |
nikmaos | 3:d4b106bf3a32 | 83 | AD1248_SPI.frequency(2500000); |
nikmaos | 3:d4b106bf3a32 | 84 | }*/ |
vitlog | 1:5d28312892aa | 85 | void SPI1_SlaveInit() |
vitlog | 1:5d28312892aa | 86 | { |
vitlog | 1:5d28312892aa | 87 | |
vitlog | 1:5d28312892aa | 88 | } |
vitlog | 1:5d28312892aa | 89 | |
vitlog | 1:5d28312892aa | 90 | |
vitlog | 1:5d28312892aa | 91 | void SPI1MasterTransmitString(unsigned char *sData,unsigned int sz) //передать строку размером sz |
vitlog | 1:5d28312892aa | 92 | { |
vitlog | 1:5d28312892aa | 93 | /* |
vitlog | 1:5d28312892aa | 94 | int i=0; |
vitlog | 1:5d28312892aa | 95 | for (i=0;i<sz;i++) |
vitlog | 1:5d28312892aa | 96 | { |
vitlog | 1:5d28312892aa | 97 | SPI1MasterTransferByte(sData[i]); |
vitlog | 1:5d28312892aa | 98 | } |
vitlog | 1:5d28312892aa | 99 | */ |
vitlog | 1:5d28312892aa | 100 | } |
vitlog | 1:5d28312892aa | 101 | |
vitlog | 1:5d28312892aa | 102 | unsigned char SPI1MasterTransferByte(unsigned char cData)//отправить и считать байт |
vitlog | 1:5d28312892aa | 103 | { |
vitlog | 1:5d28312892aa | 104 | return (unsigned char)TED2.write(cData); |
vitlog | 1:5d28312892aa | 105 | } |
nikmaos | 3:d4b106bf3a32 | 106 | /*unsigned char SPI3MasterTransferByte(unsigned char cData)//отправить и считать байт |
nikmaos | 3:d4b106bf3a32 | 107 | { |
nikmaos | 3:d4b106bf3a32 | 108 | return (unsigned char)AD1248_SPI.write(cData); |
nikmaos | 3:d4b106bf3a32 | 109 | }*/ |
vitlog | 1:5d28312892aa | 110 | |
vitlog | 1:5d28312892aa | 111 | unsigned char SPI1MasterReadByte() |
vitlog | 1:5d28312892aa | 112 | { |
vitlog | 1:5d28312892aa | 113 | return (unsigned char)TED2.write(0xFF); |
vitlog | 1:5d28312892aa | 114 | } |