/** * @ingroup DEV * * @param dmx_device_info */ static void mcp23s08_init(dmx_device_info_t * dmx_device_info) { #ifdef DEBUG printf("device init <mcp23s08>\n"); #endif mcp23s08_start(&(dmx_device_info->device_info)); mcp23s08_reg_write(&dmx_device_info->device_info, MCP23S08_IODIR, 0x00); mcp23s08_reg_write(&dmx_device_info->device_info, MCP23S08_GPIO, 0x00); }
bool RDMSubDeviceMCP23S08::Initialize(void) { const bool IsConnected = mcp23s08_start(&m_tDeviceInfo); if (IsConnected) { mcp23s08_reg_write(&m_tDeviceInfo, MCP23S08_IODIR, 0x00); mcp23s08_reg_write(&m_tDeviceInfo, MCP23S08_GPIO, 0x00); } #ifndef NDEBUG printf("%s:%s IsConnected=%d\n", __FILE__, __FUNCTION__, (int) IsConnected); #endif return IsConnected; }
void RDMSubDeviceMCP23S08::Data(const uint8_t* pData, uint16_t nLength) { uint8_t nData = 0; const uint16_t nDmxStartAddress = GetDmxStartAddress(); for (uint32_t i = nDmxStartAddress - 1, j = 0; (i < nLength) && (j < DMX_FOOTPRINT); i++, j++) { if ((pData[i] & (uint8_t) 0x80) != 0) { // 0-127 is off, 128-255 is on nData = nData | (uint8_t) (1 << j); } } #ifndef NDEBUG printf("%s:%s m_nData=%x, nData=%x\n", __FILE__, __FUNCTION__, m_nData, nData); #endif if (m_nData != nData) { mcp23s08_reg_write(&m_tDeviceInfo, MCP23S08_GPIO, nData); m_nData = nData; } }
/** * @ingroup DEV * * @param dmx_device_info */ static void mcp23s08(dmx_device_info_t * dmx_device_info) { int i = 0; unsigned char data = 0; int dmx_data_index = dmx_device_info->dmx_start_address; for (i = 0; i < 8; i++) { if (dmx_data_index > DMX_UNIVERSE_SIZE) break; if (dmx_data[dmx_data_index] & 0x80) { // 0-127 is off, 128-255 is on data = data | (1 << i); } dmx_data_index++; } mcp23s08_reg_write(&dmx_device_info->device_info, MCP23S08_GPIO, data); }
void RDMSubDeviceMCP23S08::Stop(void) { mcp23s08_reg_write(&m_tDeviceInfo, MCP23S08_GPIO, 0x00); m_nData = 0; }