test
Dependencies: ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259
PerifConfig.cpp@1:5d28312892aa, 2020-06-22 (annotated)
- Committer:
- vitlog
- Date:
- Mon Jun 22 10:06:00 2020 +0000
- Revision:
- 1:5d28312892aa
- Child:
- 3:d4b106bf3a32
22.06.2020
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*/ |
vitlog | 1:5d28312892aa | 5 | DigitalOut Cs(D10); |
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 | |
vitlog | 1:5d28312892aa | 12 | DigitalOut Reset(D8); |
vitlog | 1:5d28312892aa | 13 | DigitalIn CrdyA(D9); |
vitlog | 1:5d28312892aa | 14 | |
vitlog | 1:5d28312892aa | 15 | /*DigitalOut MOSI(D11); |
vitlog | 1:5d28312892aa | 16 | DigitalIn MISO(D12); |
vitlog | 1:5d28312892aa | 17 | DigitalOut SCK(D13);*/ |
vitlog | 1:5d28312892aa | 18 | /*Конец*/ |
vitlog | 1:5d28312892aa | 19 | |
vitlog | 1:5d28312892aa | 20 | //MOSI,MISO,SCK |
vitlog | 1:5d28312892aa | 21 | SPI TED2(D11, D12, D13); |
vitlog | 1:5d28312892aa | 22 | |
vitlog | 1:5d28312892aa | 23 | Serial UART(SERIAL_TX,SERIAL_RX,115200); |
vitlog | 1:5d28312892aa | 24 | |
vitlog | 1:5d28312892aa | 25 | |
vitlog | 1:5d28312892aa | 26 | void UART_gets(char maxcount) |
vitlog | 1:5d28312892aa | 27 | /*Функция получения строки и записи её в глобальную переменную str[]*/ |
vitlog | 1:5d28312892aa | 28 | { |
vitlog | 1:5d28312892aa | 29 | int i=0; |
vitlog | 1:5d28312892aa | 30 | do |
vitlog | 1:5d28312892aa | 31 | { |
vitlog | 1:5d28312892aa | 32 | while (UART.readable()); //перед точкой с запятой цикл |
vitlog | 1:5d28312892aa | 33 | str[i++]=UART.getc(); |
vitlog | 1:5d28312892aa | 34 | } |
vitlog | 1:5d28312892aa | 35 | while ((str[i-2]!=0x0D)&&(str[i-1]!=0x0A)); |
vitlog | 1:5d28312892aa | 36 | for (i=i;i<maxcount;i++) |
vitlog | 1:5d28312892aa | 37 | { |
vitlog | 1:5d28312892aa | 38 | str[i]='\0'; |
vitlog | 1:5d28312892aa | 39 | } |
vitlog | 1:5d28312892aa | 40 | } |
vitlog | 1:5d28312892aa | 41 | |
vitlog | 1:5d28312892aa | 42 | |
vitlog | 1:5d28312892aa | 43 | |
vitlog | 1:5d28312892aa | 44 | void DebugString (unsigned char *sData,unsigned char sz) |
vitlog | 1:5d28312892aa | 45 | { |
vitlog | 1:5d28312892aa | 46 | /* |
vitlog | 1:5d28312892aa | 47 | int i; |
vitlog | 1:5d28312892aa | 48 | for (i=0;i<sz;i++) |
vitlog | 1:5d28312892aa | 49 | { |
vitlog | 1:5d28312892aa | 50 | if (sData[i]==0x00) //если пришёл символ конца строки то не отправляем что-либо |
vitlog | 1:5d28312892aa | 51 | { |
vitlog | 1:5d28312892aa | 52 | i=sz; |
vitlog | 1:5d28312892aa | 53 | } |
vitlog | 1:5d28312892aa | 54 | else UART1_Transmit(sData[i]); |
vitlog | 1:5d28312892aa | 55 | } |
vitlog | 1:5d28312892aa | 56 | */ |
vitlog | 1:5d28312892aa | 57 | } |
vitlog | 1:5d28312892aa | 58 | |
vitlog | 1:5d28312892aa | 59 | void SPI1_MasterInitMode(char mode) |
vitlog | 1:5d28312892aa | 60 | { |
vitlog | 1:5d28312892aa | 61 | TED2.format(8,mode); |
vitlog | 1:5d28312892aa | 62 | TED2.frequency(2500000); |
vitlog | 1:5d28312892aa | 63 | } |
vitlog | 1:5d28312892aa | 64 | void SPI1_SlaveInit() |
vitlog | 1:5d28312892aa | 65 | { |
vitlog | 1:5d28312892aa | 66 | |
vitlog | 1:5d28312892aa | 67 | } |
vitlog | 1:5d28312892aa | 68 | |
vitlog | 1:5d28312892aa | 69 | |
vitlog | 1:5d28312892aa | 70 | void SPI1MasterTransmitString(unsigned char *sData,unsigned int sz) //передать строку размером sz |
vitlog | 1:5d28312892aa | 71 | { |
vitlog | 1:5d28312892aa | 72 | /* |
vitlog | 1:5d28312892aa | 73 | int i=0; |
vitlog | 1:5d28312892aa | 74 | for (i=0;i<sz;i++) |
vitlog | 1:5d28312892aa | 75 | { |
vitlog | 1:5d28312892aa | 76 | SPI1MasterTransferByte(sData[i]); |
vitlog | 1:5d28312892aa | 77 | } |
vitlog | 1:5d28312892aa | 78 | */ |
vitlog | 1:5d28312892aa | 79 | } |
vitlog | 1:5d28312892aa | 80 | |
vitlog | 1:5d28312892aa | 81 | unsigned char SPI1MasterTransferByte(unsigned char cData)//отправить и считать байт |
vitlog | 1:5d28312892aa | 82 | { |
vitlog | 1:5d28312892aa | 83 | return (unsigned char)TED2.write(cData); |
vitlog | 1:5d28312892aa | 84 | } |
vitlog | 1:5d28312892aa | 85 | |
vitlog | 1:5d28312892aa | 86 | unsigned char SPI1MasterReadByte() |
vitlog | 1:5d28312892aa | 87 | { |
vitlog | 1:5d28312892aa | 88 | return (unsigned char)TED2.write(0xFF); |
vitlog | 1:5d28312892aa | 89 | } |