当前位置: 首页>>代码示例>>C++>>正文


C++ USART::tickRising方法代码示例

本文整理汇总了C++中USART::tickRising方法的典型用法代码示例。如果您正苦于以下问题:C++ USART::tickRising方法的具体用法?C++ USART::tickRising怎么用?C++ USART::tickRising使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在USART的用法示例。


在下文中一共展示了USART::tickRising方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: spiSlave

		void spiSlave() {
			m->setByte(v->getP1SEL(), 0x31);
			m->setByte(v->getUCA0CTL1(), 0); // UCSWRST
			// UCA0CTL0 |= UCSYNC+UCMSB;
			m->setByte(v->getUCA0CTL0(), 33);
			// UCA0CTL1 &= ~UCSWRST;
			m->setByte(v->getUCA0CTL1(), 0);
			// UCA0IE |= UCRXIE | UCTXIE;
			m->setByte(v->getUC0IE(), 255);

			m->setByte(v->getUCA0TXBUF(), 55); // 00110111

			// nothing should happen, because we are slave
			CPPUNIT_ASSERT_EQUAL(-1.0, watcher->sclk);
			usart->tickRising();
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(-1.0, watcher->sclk);

			// Transfer byte
			for (int i = 0; i < 8; ++i) {
				pinManager->handlePinInput(1, 3.0);
				pinManager->handlePinInput(2, 3.0);
				pinManager->handlePinInput(2, 0.0);
				CPPUNIT_ASSERT_EQUAL((bool)(55 & (1 << (7 - i))), (bool)watcher->sdo); break;
			}

/*
		/// BIT 2
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 0.0);

			// cnt--, bit captured from SDI
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 3
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 3.0);

			// cnt--, bit captured from SDI
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 4
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 0.0);

			// cnt--, bit captured from SDI
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 5
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 3.0);

			// cnt--, bit captured from SDI
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 6
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 0.0);

			// cnt--, bit captured from SDI
			usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 7
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 3.0);
//.........这里部分代码省略.........
开发者ID:cybercircuits,项目名称:qsimkit,代码行数:101,代码来源:USART.cpp

示例2: spiMaster

		void spiMaster() {
			// TXEPT is 1 after reset
			CPPUNIT_ASSERT_EQUAL(true, m->isBitSet(v->getU0TCTL(), 1));

			m->setByte(v->getP1SEL(), 0x31);
			m->setByte(v->getU0CTL(), 0); // UCSWRST
			// UCTL0 = CHAR + SYNC + MM + SWRST;
			m->setByte(v->getU0CTL(), 23);
			// UTCTL0 = SSEL1 + SSEL0 + STC;
			m->setByte(v->getU0TCTL(), 51);
			m->setByte(v->getUC0IE(), 255);
 			// ME1 |= USPIE0;                            // Enable USART0 SPI mode
 			// UCTL0 &= ~SWRST;                          // Initialize USART state machine
			m->setByte(v->getU0ME(), 255);
			m->setByte(v->getU0CTL(), 22);
			// Set BR
			m->setByte(v->getU0BR0(), 2);

			// nothing should happen until we send character
			CPPUNIT_ASSERT_EQUAL(-1.0, watcher->sclk);
			usart->tickRising(); usart->tickFalling();
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(-1.0, watcher->sclk);
			// No transmission, TXEPT is 1
			CPPUNIT_ASSERT_EQUAL(true, m->isBitSet(v->getU0TCTL(), 1));

			// Set TX IFG just to test it gets cleared by write to TXBUF later
			m->setBit(v->getU0IFG(), 128, true);
			CPPUNIT_ASSERT_EQUAL(true, m->isBitSet(v->getU0IFG(), 128));

			// start transmitting - we will transfer 8 bits
			m->setByte(v->getU0TXBUF(), 55); // 00110111
			CPPUNIT_ASSERT_EQUAL(-1.0, watcher->sclk);

			// Write to TXBUF should clear TX IFG
			CPPUNIT_ASSERT_EQUAL(false, m->isBitSet(v->getU0IFG(), 128));
			// We are transmitting now, so TXEPT should be 0
			CPPUNIT_ASSERT_EQUAL(false, m->isBitSet(v->getU0TCTL(), 1));

			// Disable SWRST
			m->setBit(v->getU0CTL(), 1, false);

		/// BIT 1
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sdo);

			// prepare '1' to be captured
			pinManager->handlePinInput(0, 3.0);

			//  bit captured from SOMI
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 2
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 0.0);

			// cnt--, bit captured from SDI
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 3
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 3.0);

			// cnt--, bit captured from SDI
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 4
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sdo);

			// prepare '0' to be captured
			pinManager->handlePinInput(0, 0.0);

			// cnt--, bit captured from SDI
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sclk);

		/// BIT 5
			// First (MSB) bit should be sent and rising clock generated
			usart->tickRising(); usart->tickFalling();
			CPPUNIT_ASSERT_EQUAL(3.0, watcher->sclk);
			CPPUNIT_ASSERT_EQUAL(0.0, watcher->sdo);

//.........这里部分代码省略.........
开发者ID:cybercircuits,项目名称:qsimkit,代码行数:101,代码来源:USART.cpp


注:本文中的USART::tickRising方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。