本文整理汇总了C++中serial::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ serial::Init方法的具体用法?C++ serial::Init怎么用?C++ serial::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serial
的用法示例。
在下文中一共展示了serial::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
halInit();
chSysInit();
//kruciální řádky - odpojit jtag; nechat jenom swd - sou na nem piny pro SPI1
//premapovat SPI1 na PB3;4;5
RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;
AFIO->MAPR |= AFIO_MAPR_SPI1_REMAP;
AFIO->MAPR |= 0b010 << 24;
#if 1
spiStart(&SPID1, &config);
palSetPadMode(config.ssport, config.sspad, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(SPI_SCK_PORT, SPI_SCK_PIN, SPI_SCK_MODE);
palSetPadMode(SPI_MISO_PORT, SPI_MISO_PIN, SPI_MISO_MODE);
palSetPadMode(SPI_MOSI_PORT, SPI_MOSI_PIN, SPI_MOSI_MODE);
#else
palSetPadMode(config.ssport, config.sspad, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(SPI_SCK_PORT, SPI_SCK_PIN, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(SPI_MISO_PORT, SPI_MISO_PIN, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(SPI_MOSI_PORT, SPI_MOSI_PIN, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(config.ssport, config.sspad);
palClearPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
palSetPad(config.ssport, config.sspad);
palClearPad(config.ssport, config.sspad);
palClearPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
palSetPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(config.ssport, config.sspad);
palClearPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
palSetPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(config.ssport, config.sspad);
palClearPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
palSetPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
palClearPad(config.ssport, config.sspad);
palClearPad(SPI_SCK_PORT, SPI_SCK_PIN);
palClearPad(SPI_MISO_PORT, SPI_MISO_PIN);
palClearPad(SPI_MOSI_PORT, SPI_MOSI_PIN);
//
#endif
palSetPadMode(TEST_LED_PORT, TEST_LED_PIN, PAL_MODE_INPUT);
palSetPadMode(TEST_LED_PORT2, TEST_LED_PIN2, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(TEST_LED_PORT, TEST_LED_PIN);
palClearPad(TEST_LED_PORT2, TEST_LED_PIN2);
s1.Register();
palSetPadMode(GPIOA, 2, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
// palSetPad(GPIOA,2);
//DBGMCU->CR |= DBGMCU_CR_DBG_TIM2_STOP;
pwmStart(&PWMD2, &pwmcfg);
pwmEnableChannel(&PWMD2,2,PWM_PERCENTAGE_TO_WIDTH(&PWMD2,5000));
//setup watchdog
DBGMCU->CR |= DBGMCU_CR_DBG_IWDG_STOP;
IWDG->KR = 0x5555;
IWDG->PR = 6;
IWDG->RLR = 0xFFF;
IWDG->KR = 0xCCCC;
#if 1
ser.Init();
rf.begin();
rf.enableAckPayload();
rf.enableDynamicPayloads();
for (int i = 0; i < 5; i++)
rf.openReadingPipe(i, pipe + i);
rf.startListening();
#endif
while (TRUE)
{
Scheduler::Play();
ser.Loop();
sysTime = chTimeNow();
}
return 1;
}