void halBoardInit(void)
{
    halMcuInit();

    // LED
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_1_PORT, HAL_BOARD_IO_LED_1_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_3_PORT, HAL_BOARD_IO_LED_3_PIN, 0);

    HAL_LED_CLR_1();
    HAL_LED_CLR_3();

    // Button
    MCU_IO_INPUT(0, 1, MCU_IO_TRISTATE);

    // Joystick level input
    MCU_IO_INPUT(HAL_BOARD_IO_JOYSTICK_ADC_PORT, HAL_BOARD_IO_JOYSTICK_ADC_CH, \
        MCU_IO_TRISTATE);

    // Joystick push input
    MCU_IO_INPUT(HAL_BOARD_IO_JOYSTICK_PUSH_PORT, HAL_BOARD_IO_JOYSTICK_PUSH_PIN, \
        MCU_IO_TRISTATE);

    halLcdInit();
    halIntOn();
}
/***********************************************************************************
* @fn      clearDrives
*
* @brief   Stop Driving X and Y, Configure ADC Pins
*
* @param   none
*
* @return  none
*/
void clearDrives(void)
{
    MCU_IO_INPUT(0,XN_C,MCU_IO_TRISTATE);
    MCU_IO_INPUT(0,YN_C,MCU_IO_TRISTATE);
    MCU_IO_INPUT(0,XP_C,MCU_IO_TRISTATE);
    MCU_IO_INPUT(0,YP_C,MCU_IO_TRISTATE);
}
void Intitialize_Drumset()
{
  P0SEL = 0;

  MCU_IO_OUTPUT(DRUM_PORT, DR0_PIN, 1);
  MCU_IO_OUTPUT(DRUM_PORT, DR1_PIN, 1);
  MCU_IO_OUTPUT(DRUM_PORT, DR2_PIN, 1);
  MCU_IO_OUTPUT(DRUM_PORT, DR3_PIN, 1);
  MCU_IO_OUTPUT(DRUM_PORT, DR4_PIN, 1);
  MCU_IO_OUTPUT(DRUM_PORT, DR5_PIN, 1);

  MCU_IO_INPUT(DRUM_PORT, DR0_PIN, MCU_IO_PULLUP);
  MCU_IO_INPUT(DRUM_PORT, DR1_PIN, MCU_IO_PULLUP);
  MCU_IO_INPUT(DRUM_PORT, DR2_PIN, MCU_IO_PULLUP);
  MCU_IO_INPUT(DRUM_PORT, DR3_PIN, MCU_IO_PULLUP);
  MCU_IO_INPUT(DRUM_PORT, DR4_PIN, MCU_IO_PULLUP);
  MCU_IO_INPUT(DRUM_PORT, DR5_PIN, MCU_IO_PULLUP);

  MCU_IO_INPUT(DRUM_PORT, 6, MCU_IO_PULLDOWN);
  MCU_IO_INPUT(DRUM_PORT, 7, MCU_IO_PULLDOWN);


  PICTL |= 0x01;   //High to Low Edge
  PICTL |= 0x18;    //Enable Interrupts P0ENH, P0ENL
  P0IF = 0;
  P0IFG = 0;
  P0IE = 1;

  //halLedSet(1);
  //halLedSet(3);

}
void halSpiInit(uint8 clockrate)
{
    // Set up pins
    MCU_IO_INPUT(HAL_SPI_SOMI_PORT, HAL_SPI_SOMI_PIN);
    MCU_IO_OUTPUT(HAL_SPI_SIMO_PORT, HAL_SPI_SIMO_PIN, 0);
    MCU_IO_OUTPUT(HAL_SPI_CLK_PORT,  HAL_SPI_CLK_PIN, 0);
    MCU_IO_OUTPUT(HAL_SPI_CS_PORT, HAL_SPI_CS_PIN, 1);
}
/***********************************************************************************
* @fn      setTouchDrives
*
* @brief   Set Y+drive to input with pull-up, X-drive to output low
*
* @param   none
*
* @return  none
*/
void setTouchDrives(void)
{
	clearDrives();
	MCU_IO_OUTPUT(0,YP_C,1);
	MCU_IO_INPUT(0,YP_C,MCU_IO_PULLUP);
	MCU_IO_OUTPUT(0,XN_C,0);
	halMcuWaitMs(1);                                 // Wait for pin to settle
}
Exemple #6
0
/************************************************************************************
* @fn      halJoystickInit
*
* @brief   Initializes the joystick functionality
*
* @param  void
*
* @return void
*
************************************************************************************/
void halJoystickInit(void)
{
    // Joystick push input
    MCU_IO_INPUT(HAL_BOARD_IO_JOY_MOVE_PORT, HAL_BOARD_IO_JOY_MOVE_PIN, \
        MCU_IO_TRISTATE);

    // Analog input
    MCU_IO_PERIPHERAL(HAL_BOARD_IO_JOYSTICK_ADC_PORT, HAL_BOARD_IO_JOYSTICK_ADC_PIN);

#ifdef JOYSTICK_ISR
    halDigioConfig(&pinJoystickMove);
    halDigioIntSetEdge(&pinJoystickMove, HAL_DIGIO_INT_RISING_EDGE);
    halDigioIntConnect(&pinJoystickMove, &halJoystickMoveISR);
#endif
}
/******************************************************************************
* @fn  halButtonPushed
*
* @brief
*      This function detects if 'S1' is being pushed. The function
*      implements software debounce. Return true only if previuosly called
*      with button not pushed. Return true only once each time the button
*      is pressed.
*
* Parameters:
*
* @param  void
*
* @return uint8
*          1: Button is being pushed
*          0: Button is not being pushed
*
******************************************************************************/
uint8 halButtonPushed(void)
{
    extern volatile uint8 led4State;

    uint8        v= HAL_BUTTON_NONE;

    // Need to set direction because the button is shared with LED4
    MCU_IO_INPUT(HAL_BOARD_IO_BTN_1_PORT, HAL_BOARD_IO_BTN_1_PIN, MCU_IO_TRISTATE);

    if (HAL_BUTTON_1_PUSHED()) {
        HAL_DEBOUNCE(!HAL_BUTTON_1_PUSHED());
        v= HAL_BUTTON_1;
    }
    // Restore for use with LED
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_4_PORT, HAL_BOARD_IO_LED_4_PIN, led4State);

    return v;
}
Exemple #8
0
/******************************************************************************
* @fn  halButtonInit
*
* @brief
*      Initializes the button functionality
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void halButtonInit(void)
{
    // Button push input
    MCU_IO_INPUT(HAL_BOARD_IO_BTN_1_PORT, HAL_BOARD_IO_BTN_1_PIN, MCU_IO_TRISTATE);
}