You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.8 KiB

//#####################################################################################################################################################################################################
// idiBus_Ext_4xADC0-10_APPL
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include "config.h"
#include <avr/io.h>
FUSES={ .extended=F_Ext, .high = F_High, .low = F_Low }; // Fuses + Lock programming
LOCKBITS=F_Lock;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include "USART0.h"
#include "USART1.h"
#include "SPI.h"
#include "USART0Custom.h"
#include "RSLink.h"
#include "RSLinkCustom.h"
#include <avr/wdt.h>
#include "SYSTEMCustom.h"
#include "Common/MEMORY.h"
#include "IDIBUS_IMPL_Custom.h"
//#####################################################################################################################################################################################################
//uint8_t data_to_send[12] = {0x05, 0x4E, 0x20, 0x28, 0x01, 0x00, 0x01, 0x9C, 0x40, 0x28, 0x01, 0x01};
int start_flag = 0;
int main(void)
{
//DDRD = 3; // USART PD0, PD1
//PORTD = 3;
///////////////////////////////
//STM NRST
DDRC = 0;
PORTC = 0;
///////////////////////////////
//DDRE |= (1 << PORTE1);
//PORTE = 2;
cli(); // Çàïðåò ïðåðûâàíèé
wdt_enable(WDTO_2S); // Watchdog òàéìåð íà 2 ñåê
wdt_reset(); // Ñáðîñ watchdog òàéìåðà, ÷òîá íå ñðàáàòûâàë ïðîñòî òàê
System_InitSysTick(); // Èíèöèàëèçàöèÿ ñèñòåìíîãî ñ÷åò÷èêà âðåìåíè
System_SystickTimerStart(); // Çàïóñê ñèñòåìíîãî ñ÷åò÷èêà âðåìåíè
//USART0_Init();
//USART0_INTERFACE.SetNewBaudrate(115200);
//USART_Init(8);
USART1_Init();
IDIBUS_ModuleInit(&USART1_INTERFACE, &STATIC_DATA_APP.Padding);
RSLink_Init(&USART1_INTERFACE, &USART1_IDIBUS);
sei(); //Find some place for this
//uint8_t buf[3] = {'S','6'};
//USART0_INTERFACE.SendByteBuf(&buf,2);
// -----SPI-----
SPI_MasterInit();
//for (uint8_t i = 0; i < 12; i++) {
//USART_Transmit(data_to_send[i]);
//}
while (1)
{
if (start_flag == 0) {
STMReset();
start_flag = 1;
}
RSLink_Handler();
//for (uint8_t i = 0; i < 12; i++) {
//data_to_send[i] = USART_Receive();
//}
//_delay_ms(100);
//STMReset();
//_delay_ms(100);
//if ((PINC)&(1<<PORTC3)) { // STM ãîòîâ ê ïðèåìó
//_delay_ms(100);
//for (int i = 0; i < 12; i++) {
//SPI_MasterTransmit(data_to_send[i]);
//}
//}
wdt_reset();
}
}
//#####################################################################################################################################################################################################