int main(void)
{
  // TivaC application specific code
  MAP_FPUEnable();
  MAP_FPULazyStackingEnable();
  // TivaC system clock configuration. Set to 80MHz.
  MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

  uint8_t button_debounced_delta;
  uint8_t button_raw_state;
  ButtonsInit();

  // ROS nodehandle initialization and topic registration
  nh.initNode();
  nh.advertise(button_publisher);

  while (1)
  {
    uint8_t button_debounced_state = ButtonsPoll(&button_debounced_delta, &button_raw_state);
    // Publish message to be transmitted.
    button_msg.sw1.data = button_debounced_state & LEFT_BUTTON;
    button_msg.sw2.data = button_debounced_state & RIGHT_BUTTON;
    button_publisher.publish(&button_msg);

    // Handle all communications and callbacks.
    nh.spinOnce();

    // Delay for a bit.
    nh.getHardware()->delay(100);
  }
}
Esempio n. 2
0
void setup() 
{
  RelayShield::begin();

  node_handle.getHardware()->setBaud(115200);
  node_handle.initNode();

  node_handle.subscribe(relay_subscriber);
}
int main(void)
{  
  SetSysClockTo56();
  
  // ROS nodehandle initialization and topic registration
  nh.initNode();
  nh.advertise(chatter);

  // Initialize LED
  GPIO_InitTypeDef GPIO_Config;
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  GPIO_Config.GPIO_Pin =  GPIO_Pin_5;
  GPIO_Config.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Config.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_Config);
  GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET);
  
  while (1)
  {
    // Toggle LED
    if (GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_5))
      GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_RESET);
    else
      GPIO_WriteBit(GPIOB, GPIO_Pin_5, Bit_SET);

    // Publish message to be transmitted.
    str_msg.data = hello;
    chatter.publish(&str_msg);

    // Handle all communications and callbacks.
    nh.spinOnce();
    
    // Delay for a bit.
    nh.getHardware()->delay(100);
  }
}