예제 #1
0
파일: main.c 프로젝트: hmchen1/ChibiOS-RT
/*
 * Application entry point.
 */
int main(void) {
    unsigned i;

    /*
     * System initializations.
     * - HAL initialization, this also initializes the configured device drivers
     *   and performs the board-specific initializations.
     * - Kernel initialization, the main() function becomes a thread and the
     *   RTOS is active.
     */
    halInit();
    chSysInit();

    /*
     * Prepare transmit pattern.
     */
    for (i = 0; i < sizeof(txbuf); i++)
        txbuf[i] = (uint8_t)i;

    /* Starting driver for test, DSPI_B I/O pins setup.*/
    spiStart(&SPID2, &ls_spicfg);
    SIU.PCR[102].R = PAL_MODE_OUTPUT_ALTERNATE(1);    /* SCK    */
    SIU.PCR[103].R = PAL_MODE_OUTPUT_ALTERNATE(1);    /* SIN    */
    SIU.PCR[104].R = PAL_MODE_OUTPUT_ALTERNATE(1);    /* SOUT   */
    SIU.PCR[105].R = PAL_MODE_OUTPUT_ALTERNATE(1);    /* PCS[0] */
    SIU.PCR[106].R = PAL_MODE_OUTPUT_ALTERNATE(1);    /* PCS[1] */

    /* Testing sending and receiving at the same time.*/
    spiExchange(&SPID2, 4, txbuf, rxbuf);
    spiExchange(&SPID2, 32, txbuf, rxbuf);
    spiExchange(&SPID2, 512, txbuf, rxbuf);

    /* Testing clock pulses without data buffering.*/
    spiIgnore(&SPID2, 4);
    spiIgnore(&SPID2, 32);

    /* Testing sending data ignoring incoming data.*/
    spiSend(&SPID2, 4, txbuf);
    spiSend(&SPID2, 32, txbuf);

    /* Testing receiving data while sending idle bits (high level).*/
    spiReceive(&SPID2, 4, rxbuf);
    spiReceive(&SPID2, 32, rxbuf);

    /* Testing stop procedure.*/
    spiStop(&SPID2);

    /*
     * Starting the transmitter and receiver threads.
     */
    chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
                      NORMALPRIO + 1, spi_thread_1, NULL);
    chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa),
                      NORMALPRIO + 1, spi_thread_2, NULL);

    /*
     * Normal main() thread activity, in this demo it does nothing.
     */
    while (TRUE) {
        chThdSleepMilliseconds(500);
        palTogglePad(PORT11, P11_LED2);
    }
    return 0;
}
예제 #2
0
        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#include "hal.h"

#if HAL_USE_PAL || defined(__DOXYGEN__)
/* Initial setup of all defined pads, the list is terminated by a {-1, 0, 0}.*/
static const spc_siu_init_t spc_siu_init[] = {
  {PCR(PORT_B, PB_LIN0_TDX), PAL_HIGH,   PAL_MODE_OUTPUT_ALTERNATE(1)},
  {PCR(PORT_B, PB_LIN0_RDX), PAL_HIGH,   PAL_MODE_INPUT},
  {PCR(PORT_D, PD_BUTTON1), PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT_D, PD_BUTTON2), PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT_D, PD_BUTTON3), PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT_D, PD_BUTTON4), PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT_D, PD_LED1),    PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT_D, PD_LED2),    PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT_D, PD_LED3),    PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT_D, PD_LED4),    PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {-1, 0, 0}
};

/* Initialization array for the PSMI registers.*/
static const uint8_t spc_padsels_init[SPC5_SIUL_NUM_PADSELS] = {
  0,   0,   0,   0,   0,   0,   0,   0,   
예제 #3
0
        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#include "hal.h"

#if HAL_USE_PAL || defined(__DOXYGEN__)
/* Initial setup of all defined pads, the list is terminated by a {-1, 0, 0}.*/
static const spc_siu_init_t spc_siu_init[] = {
  {PCR(PORT5, P5_ESCI_A_TX),      PAL_HIGH,   PAL_MODE_OUTPUT_ALTERNATE(1)},
  {PCR(PORT5, P5_ESCI_A_RX),      PAL_HIGH,   PAL_MODE_OUTPUT_ALTERNATE(1)},
  {PCR(PORT11, P11_BUTTON1),      PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT11, P11_BUTTON2),      PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT11, P11_BUTTON3),      PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT11, P11_BUTTON4),      PAL_LOW,    PAL_MODE_INPUT},
  {PCR(PORT11, P11_LED1),         PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT11, P11_LED2),         PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT11, P11_LED3),         PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {PCR(PORT11, P11_LED4),         PAL_HIGH,   PAL_MODE_OUTPUT_PUSHPULL},
  {-1, 0, 0}
};

/**
 * @brief   PAL setup.
 */