|
|
|
|
//#####################################################################################################################################################################################################
|
|
|
|
|
// 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(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
wdt_enable(WDTO_2S); // Watchdog <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 2 <20><><EFBFBD>
|
|
|
|
|
wdt_reset(); // <20><><EFBFBD><EFBFBD><EFBFBD> watchdog <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
|
|
|
|
System_InitSysTick(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
System_SystickTimerStart(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//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 <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//_delay_ms(100);
|
|
|
|
|
//for (int i = 0; i < 12; i++) {
|
|
|
|
|
//SPI_MasterTransmit(data_to_send[i]);
|
|
|
|
|
//}
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
wdt_reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#####################################################################################################################################################################################################
|