|
|
|
|
//#############################################################################################################################################################################################################
|
|
|
|
|
#include "RSLinkCustom.h"
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void RSLink_StatusLedInit(void) // Status led Init
|
|
|
|
|
{
|
|
|
|
|
RSLINK_LED_DDR|=1<<RSLINK_LED_BIT;
|
|
|
|
|
RSLINK_LED_PORT&=~(1<<RSLINK_LED_BIT);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void RSLink_StatusLedSetOn(void) // Status led On
|
|
|
|
|
{
|
|
|
|
|
RSLINK_LED_PORT|=1<<RSLINK_LED_BIT;
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void RSLink_StatusLedSetOff(void) // Status led Off
|
|
|
|
|
{
|
|
|
|
|
RSLINK_LED_PORT&=~(1<<RSLINK_LED_BIT);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
// FOR 328pb
|
|
|
|
|
void RSLink_DipsInit(void) // Dip switch Adders, Speed, Bus Type Init
|
|
|
|
|
{
|
|
|
|
|
RSLINK_DIPS_CP_DDR|=1<<RSLINK_DIPS_CP_BIT; RSLINK_DIPS_CP_PORT|=1<<RSLINK_DIPS_CP_BIT; // clock, output -> 1
|
|
|
|
|
RSLINK_DIPS_nPL_DDR|=1<<RSLINK_DIPS_nPL_BIT; RSLINK_DIPS_nPL_PORT|=1<<RSLINK_DIPS_nPL_BIT; // latch, output -> 1
|
|
|
|
|
RSLINK_DIPS_Q7_DDR&=~(1<<RSLINK_DIPS_Q7_BIT); RSLINK_DIPS_Q7_PORT&=~(1<<RSLINK_DIPS_Q7_BIT); // data, input
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
// FOR 328pb
|
|
|
|
|
uint16_t RSLink_DipsRead(void) // Dip switch Adders, Speed, Bus Type Read
|
|
|
|
|
{
|
|
|
|
|
// RESULT = [ADDR7...0][XXXX][TYPE][SS2...0]
|
|
|
|
|
RSLINK_DIPS_nPL_PORT&=~(1<<RSLINK_DIPS_nPL_BIT);
|
|
|
|
|
uint16_t STATE=0;
|
|
|
|
|
RSLINK_DIPS_nPL_PORT|=1<<RSLINK_DIPS_nPL_BIT;
|
|
|
|
|
for (uint8_t I=0; I<16; I++)
|
|
|
|
|
{
|
|
|
|
|
STATE=STATE<<1;
|
|
|
|
|
RSLINK_DIPS_CP_PORT&=~(1<<RSLINK_DIPS_CP_BIT);
|
|
|
|
|
if ((RSLINK_DIPS_Q7_PIN&(1<<RSLINK_DIPS_Q7_BIT))!=0) STATE|=0x0001;
|
|
|
|
|
RSLINK_DIPS_CP_PORT|=1<<RSLINK_DIPS_CP_BIT;
|
|
|
|
|
}
|
|
|
|
|
return STATE&0xFF0F;
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
uint8_t RSLink_SpeedDecode(void){
|
|
|
|
|
return (uint8_t)(RSLink_DipsRead()&0x07);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t RSLink_AddrDecode(void){
|
|
|
|
|
return (uint8_t)(RSLink_DipsRead()>>8);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
//#############################################################################################################################################################################################################
|
|
|
|
|
//void RSLink_TimerInit() {
|
|
|
|
|
////TCCR2A |= (1 << WGM21);
|
|
|
|
|
////TCCR2A &= ~(1 << WGM20); // CTC Mode
|
|
|
|
|
////TCCR2B &= ~(1 << WGM22);
|
|
|
|
|
////
|
|
|
|
|
//////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<><31><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> OCR1A(H <20> L)
|
|
|
|
|
////TIMSK2 |= (1 << OCIE2A);
|
|
|
|
|
////
|
|
|
|
|
////OCR2A = 0xFF;
|
|
|
|
|
////
|
|
|
|
|
////TCCR2B |= (1 << CS20) | (1 << CS22) | (1 << CS21);
|
|
|
|
|
//
|
|
|
|
|
//TCCR1A |= (1 << WGM12) | (1 << WGM13);
|
|
|
|
|
//TCCR1A &= ~(1 << WGM11); // CTC Mode
|
|
|
|
|
//TCCR1B &= ~(1 << WGM10);
|
|
|
|
|
//
|
|
|
|
|
//TIMSK1 |= (1 << OCIE1A);
|
|
|
|
|
//
|
|
|
|
|
//OCR1AH = 0x27; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//OCR1AL = 0x10;
|
|
|
|
|
//
|
|
|
|
|
//TCCR1B |= (1 << CS12);
|
|
|
|
|
//}
|