test

Dependencies:   ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259

Committer:
nikmaos
Date:
Fri Aug 14 14:16:03 2020 +0000
Revision:
6:cfe7cb0bdb1a
Parent:
5:21240fa1ee4c
Child:
7:c364201bc3ed
1408

Who changed what in which revision?

UserRevisionLine numberNew 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 6:cfe7cb0bdb1a 5 DigitalOut Cs(PE_4);
nikmaos 6:cfe7cb0bdb1a 6 DigitalOut En1(PE_3);
vitlog 1:5d28312892aa 7
nikmaos 6:cfe7cb0bdb1a 8 DigitalOut Adr0(PF_0);
nikmaos 6:cfe7cb0bdb1a 9 DigitalOut Adr1(PF_1);
nikmaos 6:cfe7cb0bdb1a 10 DigitalOut Adr2(PF_2);
nikmaos 3:d4b106bf3a32 11
nikmaos 6:cfe7cb0bdb1a 12 DigitalOut Reset(PA_7);
nikmaos 6:cfe7cb0bdb1a 13 DigitalIn CrdyA(PF_10);
nikmaos 3:d4b106bf3a32 14
nikmaos 6:cfe7cb0bdb1a 15 //SPI TED2(PE_6,PE_5,PE_2);//MOSI,MISO,SCK
nikmaos 6:cfe7cb0bdb1a 16 //Конец
vitlog 1:5d28312892aa 17
nikmaos 3:d4b106bf3a32 18 /*Плата СБ-1*/
nikmaos 3:d4b106bf3a32 19 DigitalOut SB1_SWEN(PB_13);
nikmaos 3:d4b106bf3a32 20 DigitalIn PosAr(PB_12);
nikmaos 3:d4b106bf3a32 21 DigitalIn PosBr(PA_15);
nikmaos 3:d4b106bf3a32 22 DigitalOut SB1_SHDN(PC_6);
nikmaos 3:d4b106bf3a32 23 DigitalOut PosAw(PB_15);
nikmaos 3:d4b106bf3a32 24 DigitalOut PosBw(PC_7);
nikmaos 6:cfe7cb0bdb1a 25
nikmaos 6:cfe7cb0bdb1a 26 DigitalOut ads1259_pin_Start(PG_2);
nikmaos 6:cfe7cb0bdb1a 27 DigitalOut ads1259_pin_CS(PD_2);
nikmaos 6:cfe7cb0bdb1a 28 DigitalIn ads1259_pin_Drdy(PG_3);
nikmaos 6:cfe7cb0bdb1a 29
nikmaos 6:cfe7cb0bdb1a 30 SPI AD1248_SPI(PC_12, PC_11, PC_10);//MOSI,MISO,SCK
nikmaos 3:d4b106bf3a32 31 /*Конец*/
nikmaos 3:d4b106bf3a32 32
nikmaos 5:21240fa1ee4c 33 //выводы для костыльного SPI для ЦАП
nikmaos 6:cfe7cb0bdb1a 34 DigitalOut LTC1446_CS(D7);
nikmaos 6:cfe7cb0bdb1a 35 DigitalOut LTC1446_CLK(D6);
nikmaos 6:cfe7cb0bdb1a 36 DigitalOut LTC1446_DOUT(D5);
vitlog 1:5d28312892aa 37 /*Конец*/
vitlog 1:5d28312892aa 38
nikmaos 6:cfe7cb0bdb1a 39
nikmaos 6:cfe7cb0bdb1a 40
nikmaos 6:cfe7cb0bdb1a 41
nikmaos 3:d4b106bf3a32 42 Serial UART(SERIAL_TX,SERIAL_RX,9600);
nikmaos 3:d4b106bf3a32 43 extern PwmOut Pressure(D3);
vitlog 1:5d28312892aa 44
vitlog 1:5d28312892aa 45 void UART_gets(char maxcount)
vitlog 1:5d28312892aa 46 /*Функция получения строки и записи её в глобальную переменную str[]*/
vitlog 1:5d28312892aa 47 {
vitlog 1:5d28312892aa 48 int i=0;
vitlog 1:5d28312892aa 49 do
vitlog 1:5d28312892aa 50 {
nikmaos 4:d53895f65eb7 51 while (UART.readable()) //перед точкой с запятой цикл (убрал)
vitlog 1:5d28312892aa 52 str[i++]=UART.getc();
vitlog 1:5d28312892aa 53 }
vitlog 1:5d28312892aa 54 while ((str[i-2]!=0x0D)&&(str[i-1]!=0x0A));
vitlog 1:5d28312892aa 55 for (i=i;i<maxcount;i++)
vitlog 1:5d28312892aa 56 {
vitlog 1:5d28312892aa 57 str[i]='\0';
vitlog 1:5d28312892aa 58 }
vitlog 1:5d28312892aa 59 }
vitlog 1:5d28312892aa 60
vitlog 1:5d28312892aa 61
vitlog 1:5d28312892aa 62
vitlog 1:5d28312892aa 63 void DebugString (unsigned char *sData,unsigned char sz)
vitlog 1:5d28312892aa 64 {
vitlog 1:5d28312892aa 65 /*
vitlog 1:5d28312892aa 66 int i;
vitlog 1:5d28312892aa 67 for (i=0;i<sz;i++)
vitlog 1:5d28312892aa 68 {
vitlog 1:5d28312892aa 69 if (sData[i]==0x00) //если пришёл символ конца строки то не отправляем что-либо
vitlog 1:5d28312892aa 70 {
vitlog 1:5d28312892aa 71 i=sz;
vitlog 1:5d28312892aa 72 }
vitlog 1:5d28312892aa 73 else UART1_Transmit(sData[i]);
vitlog 1:5d28312892aa 74 }
vitlog 1:5d28312892aa 75 */
vitlog 1:5d28312892aa 76 }
vitlog 1:5d28312892aa 77
vitlog 1:5d28312892aa 78 void SPI1_MasterInitMode(char mode)
vitlog 1:5d28312892aa 79 {
nikmaos 6:cfe7cb0bdb1a 80 AD1248_SPI.format(8,mode);
nikmaos 6:cfe7cb0bdb1a 81 AD1248_SPI.frequency(20000000);
vitlog 1:5d28312892aa 82 }
nikmaos 3:d4b106bf3a32 83 /*void SPI3_MasterInitMode(char mode)
nikmaos 3:d4b106bf3a32 84 {
nikmaos 6:cfe7cb0bdb1a 85 TED2.format(8,mode);
nikmaos 6:cfe7cb0bdb1a 86 TED2.frequency(100000);
nikmaos 3:d4b106bf3a32 87 }*/
vitlog 1:5d28312892aa 88 void SPI1_SlaveInit()
vitlog 1:5d28312892aa 89 {
vitlog 1:5d28312892aa 90
vitlog 1:5d28312892aa 91 }
vitlog 1:5d28312892aa 92
vitlog 1:5d28312892aa 93
vitlog 1:5d28312892aa 94 void SPI1MasterTransmitString(unsigned char *sData,unsigned int sz) //передать строку размером sz
vitlog 1:5d28312892aa 95 {
vitlog 1:5d28312892aa 96 /*
vitlog 1:5d28312892aa 97 int i=0;
vitlog 1:5d28312892aa 98 for (i=0;i<sz;i++)
vitlog 1:5d28312892aa 99 {
vitlog 1:5d28312892aa 100 SPI1MasterTransferByte(sData[i]);
vitlog 1:5d28312892aa 101 }
vitlog 1:5d28312892aa 102 */
vitlog 1:5d28312892aa 103 }
vitlog 1:5d28312892aa 104
vitlog 1:5d28312892aa 105 unsigned char SPI1MasterTransferByte(unsigned char cData)//отправить и считать байт
vitlog 1:5d28312892aa 106 {
nikmaos 6:cfe7cb0bdb1a 107 return (unsigned char)AD1248_SPI.write(cData);
vitlog 1:5d28312892aa 108 }
nikmaos 3:d4b106bf3a32 109 /*unsigned char SPI3MasterTransferByte(unsigned char cData)//отправить и считать байт
nikmaos 3:d4b106bf3a32 110 {
nikmaos 6:cfe7cb0bdb1a 111 return (unsigned char)TED2.write(cData);
nikmaos 3:d4b106bf3a32 112 }*/
vitlog 1:5d28312892aa 113
vitlog 1:5d28312892aa 114 unsigned char SPI1MasterReadByte()
vitlog 1:5d28312892aa 115 {
nikmaos 6:cfe7cb0bdb1a 116 return (unsigned char)AD1248_SPI.write(0xFF);
vitlog 1:5d28312892aa 117 }