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 setYDrive * * @brief Drive Y+drive High and Y-drive Low, Configure ADC Pins * * @param none * * @return none */ void setYDrive(void) { clearDrives(); MCU_IO_OUTPUT(0,YP_C,1); MCU_IO_OUTPUT(0,YN_C,0); halMcuWaitMs(1); // Delay to allow settling }
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 }
void halSpiInit(uint8 clockrate) { // Keep peripheral in reset state U1CTL = SWRST; // 8-bit SPI Master 3-pin mode, with SMCLK as clock source U1CTL |= CHAR + SYNC + MM; U1TCTL |= CKPH + SSEL1 + SSEL0 + STC; // Ignore clockrate argument for now, just use clock source/2 U1BR0 = 0x02; U1BR1 = 0x00; U1MCTL = 0x00; // Enable SPI mode ME2 |= USPIE1; // Set up pins used by peripheral unit MCU_IO_PERIPHERAL(HAL_SPI_SOMI_PORT, HAL_SPI_SOMI_PIN); MCU_IO_PERIPHERAL(HAL_SPI_SIMO_PORT, HAL_SPI_SIMO_PIN); MCU_IO_PERIPHERAL(HAL_SPI_CLK_PORT, HAL_SPI_CLK_PIN); MCU_IO_OUTPUT(HAL_SPI_CS_PORT, HAL_SPI_CS_PIN, 1); // Release for operation U1CTL &= ~SWRST; }
void halSpiInit(uint8 clockrate) { // Keep peripheral in reset state USICTL0 = USISWRST; // 8-bit SPI Master 3-pin mode USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; USICTL1 = USICKPH; // Use SMCLK as clock source, bit rate is clock source/2 USICKCTL = USIDIV0 + USISSEL1; // Set up pins used by peripheral unit MCU_IO_PERIPHERAL(HAL_SPI_SOMI_PORT, HAL_SPI_SOMI_PIN); MCU_IO_PERIPHERAL(HAL_SPI_SIMO_PORT, HAL_SPI_SIMO_PIN); MCU_IO_PERIPHERAL(HAL_SPI_CLK_PORT, HAL_SPI_CLK_PIN); MCU_IO_OUTPUT(HAL_SPI_CS_PORT, HAL_SPI_CS_PIN, 1); // Release for operation USICTL0 &= ~USISWRST; // Ensure SDO (SIMO) low USISRL = 0x00; USICNT = 1; }
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); halIntOn(); }
void midiReset() { //MIDI_RESET = 1; MCU_IO_OUTPUT(1,1,1); //delay_millisec(100); halMcuWaitMs(100); MCU_IO_OUTPUT(1,1,0); //MIDI_RESET = 0; //delay_millisec(100); halMcuWaitMs(100); //MIDI_RESET = 1; MCU_IO_OUTPUT(1,1,1); //delay_millisec(100); halMcuWaitMs(200); }
/****************************************************************************** * @fn halBoardInit * * @brief Sets up board. Initialize MCU with HS XOSC, configure I/O pins * and user interface. * * @param none * * @return none *****************************************************************************/ void halBoardInit(void) { // Enable HS XOSC and set maximum clock speed halMcuInit(); // LED MCU_IO_OUTPUT(HAL_BOARD_IO_LED_PORT, HAL_BOARD_IO_LED_PIN, 0); // Turn off }
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); }
/****************************************************************************** * @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; }
void halSpiInit(uint8 clockrate) { // Keep peripheral in reset state UCA0CTL1 = UCSWRST; // 8-bit SPI Master 3-pin mode, with SMCLK as clock source UCA0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; UCA0CTL1 |= UCSSEL1 + UCSSEL0; // Ignore clockrate argument for now, just use clock source/2 UCA0BR0 = 0x02; UCA0BR1 = 0x00; // Set up pins used by peripheral unit MCU_IO_PERIPHERAL(HAL_SPI_SOMI_PORT, HAL_SPI_SOMI_PIN); MCU_IO_PERIPHERAL(HAL_SPI_SIMO_PORT, HAL_SPI_SIMO_PIN); MCU_IO_PERIPHERAL(HAL_SPI_CLK_PORT, HAL_SPI_CLK_PIN); MCU_IO_OUTPUT(HAL_SPI_CS_PORT, HAL_SPI_CS_PIN, 1); // Release for operation UCA0CTL1 &= ~UCSWRST; }