#include "idibus_hw.h" #include "config.h" //============================================================================= // RSLINK MCU SPECIFIC FUNCTIONS SECTION // This example is typical Idibus_Ext with shift register //============================================================================= //----------------------------------------------------------------------------- // Status LED functions //----------------------------------------------------------------------------- void RSLink_StatusLedInit(void) // Status led Init { RSLINK_LED_DDR|=1< 1 RSLINK_DIPS_CP_DDR |= (1 << RSLINK_DIPS_CP_BIT); RSLINK_DIPS_CP_PORT |= (1 << RSLINK_DIPS_CP_BIT); // Latch, output -> 1 RSLINK_DIPS_nPL_DDR |= (1 << RSLINK_DIPS_nPL_BIT); RSLINK_DIPS_nPL_PORT |= (1 << RSLINK_DIPS_nPL_BIT); // Data, input RSLINK_DIPS_Q7_DDR &= ~(1 << RSLINK_DIPS_Q7_BIT); RSLINK_DIPS_Q7_PORT &= ~(1 << RSLINK_DIPS_Q7_BIT); } //----------------------------------------------------------------------------- static 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() { return (uint8_t)(RSLink_DipsRead() & 0x07); } uint8_t RSLink_AddrDecode() { return (uint8_t)(RSLink_DipsRead() >> 8); } #endif #ifdef _CUSTOM_TYPE_ //Define custom type here #endif