void CReagentAreaCtrl::OnLButtonUp(UINT nFlags, CPoint point) { // 如果是“概况”窗口内的控件,则不响应此消息 if(m_ControlType == raForShowing) return ; Reagent_Pos pos; _WhichNode(point,pos); if (m_bIsLButtonDown == TRUE) { m_bIsLButtonDown = FALSE; // 重绘焦点位置 _InvalidPos(pos); // 如果本节点已经设置过试剂,则弹出菜单,否则弹出“选择试剂”对话框 ReagentConfigNode *pNode = m_pReagentData->GetNode(pos); if(pNode->IsSetingReagent) { // 弹出菜单 _DisplayMenu(); } else { // 弹出“选择试剂”对话框 OnClickMenuReagentSelect(); } } CStatic::OnLButtonUp(nFlags, point); }
/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ extern int main(void) { uint8_t ucKey; /* Disable watchdog */ WDT_Disable(WDT); SCB_EnableICache(); SCB_EnableDCache(); /* Output example information */ printf("-- USART LON Example %s --\n\r", SOFTPACK_VERSION); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s With %s--\n\r", __DATE__, __TIME__, COMPILER_NAME); /* Configure pins */ PIO_Configure(pins, PIO_LISTSIZE(pins)); /* PB4 function selected */ MATRIX->MATRIX_WPMR = MATRIX_WPMR_WPKEY_PASSWD; MATRIX->CCFG_SYSIO |= CCFG_SYSIO_SYSIO4; /* Display menu */ _DisplayMenu(); /* Configure DMA with IRQ */ _ConfigureDma(); Buffer[0] = sizeof(palette) - 1; /* LON Data Length: */ Buffer[1] = US_LONL2HDR_BLI(2); memcpy(&Buffer[2], palette, sizeof(palette)); /* configure USART in LON mode*/ _ConfigureUsart(); NVIC_EnableIRQ(XDMAC_IRQn); while (1) { ucKey = DBG_GetChar(); switch (ucKey) { case 't': case 'T': printf("-I- LON Transmitting ... \n\r"); USART->US_CR = US_CR_RSTSTA; /* Reset Status Bits */ _DmaUsartTx(); while (!transDone); printf("-I- LON Transmitting completed \n\r"); transDone = 0; break; case 'r': case 'R': printf("-I- LON receiving ... \n\r"); USART->US_CR = US_CR_RSTSTA; /* Reset Status Bits */ recvDone = 0; _DmaUsartRx(); while (!recvDone); /* successfully received */ _DumpInfo(pRecvBufferUSART, BUFFER_SIZE - 1); printf("\n\r-I- LON Receiving completed \n\r"); memset(pRecvBufferUSART, 0, sizeof(pRecvBufferUSART)); break; case 'm': case 'M': _DisplayMenu(); break; } } }
/** * \brief periph-protect Application entry point. * * \return Unused (ANSI-C compatibility). */ extern int main(void) { uint8_t cmd; uint32_t wpsr; uint32_t *pReg; const uint32_t dummy = 0x12345678; /* Disable watchdog */ WDT_Disable(WDT); /* Enable I and D cache */ SCB_EnableICache(); SCB_EnableDCache(); /* Output example information */ printf("-- Peripheral Protect Example %s --\n\r", SOFTPACK_VERSION); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); _DisplayMenu(); /* Enable PIO controller peripheral clock */ PMC_EnablePeripheral(pinwp.id); /* Get the address of PIO controller to be write-protected */ pReg = _GetPioFromPin(&pinwp); while (1) { cmd = DBG_GetChar(); switch (cmd) { case 'm': _DisplayMenu(); break; case 'l': PIO_EnableWriteProtect(&pinwp); printf("The Write Protect is enabled.\r\n"); break; case 'u': PIO_DisableWriteProtect(&pinwp); printf("The Write Protect is disabled.\r\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': *(pReg + offset[cmd - '0'] / 4) = dummy; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': *(pReg + offset[cmd - 'a' + 10] / 4) = dummy; break; default: cmd = 'x'; break; } if ((cmd != 'x') && (cmd != 'm') && (cmd != 'l') && (cmd != 'u')) { /* A write access has been attempted */ wpsr = PIO_GetWriteProtectViolationInfo(&pinwp); if ((wpsr & PIO_WPMR_WPEN_EN) == PIO_WPMR_WPEN_EN) { /* Write protect violation is detected */ printf("Write protect violation is detected!\r\n"); printf("The offset of the write-protected register is 0x%04x.\r\n", (unsigned int)((wpsr & 0x00FFFF00) >> 8)); } else {
/** * \brief Application entry point for PWM with PDC example. * * Outputs a PWM on LED1 & LED2 & LED3 to makes it fade in repeatedly. * Channel #0, #1, #2 are linked together as synchronous channels, so they have * the same source clock, the same period, the same alignment and * are started together. The update of the duty cycle values is made * automatically by the Peripheral DMA Controller (PDC). * * \return Unused (ANSI-C compatibility). */ int main(void) { uint32_t i; uint8_t key; int32_t numkey; /* Disable watchdog */ WDT_Disable( WDT ) ; /* Output example information */ printf("-- PWM with PDC Example %s --\n\r", SOFTPACK_VERSION); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); /* PIO configuration */ PIO_Configure(pins, PIO_LISTSIZE(pins)); /* Enable PWMC peripheral clock */ PMC_EnablePeripheral(ID_PWM); /* Set clock A to run at PWM_FREQUENCY * MAX_DUTY_CYCLE (clock B is not used) */ PWMC_ConfigureClocks(PWM_FREQUENCY * MAX_DUTY_CYCLE, 0, BOARD_MCK); /* Configure PWMC channel for LED0 (left-aligned, enable dead time generator) */ PWMC_ConfigureChannelExt( PWM, CHANNEL_PWM_LED0, /* channel */ PWM_CMR_CPRE_CKA, /* prescaler */ 0, /* alignment */ 0, /* polarity */ 0, /* countEventSelect */ PWM_CMR_DTE, /* DTEnable */ 0, /* DTHInverte */ 0 ); /* DTLInverte */ PWMC_SetPeriod(PWM, CHANNEL_PWM_LED0, MAX_DUTY_CYCLE); PWMC_SetDutyCycle(PWM, CHANNEL_PWM_LED0, MIN_DUTY_CYCLE); PWMC_SetDeadTime(PWM, CHANNEL_PWM_LED0, 5, 5); /* Configure PWMC channel for LED1 */ PWMC_ConfigureChannelExt( PWM, CHANNEL_PWM_LED1, /* channel */ PWM_CMR_CPRE_CKA, /* prescaler */ 0, /* alignment */ 0, /* polarity */ 0, /* countEventSelect */ 0, /* DTEnable */ 0, /* DTHInverte */ 0 ); /* DTLInverte */ PWMC_SetPeriod(PWM, CHANNEL_PWM_LED1, MAX_DUTY_CYCLE); PWMC_SetDutyCycle(PWM, CHANNEL_PWM_LED1, MIN_DUTY_CYCLE); /* Configure PWMC channel for LED2 */ PWMC_ConfigureChannelExt( PWM, CHANNEL_PWM_LED2, /* channel */ PWM_CMR_CPRE_CKA, /* prescaler */ 0, /* alignment */ 0, /* polarity */ 0, /* countEventSelect */ 0, /* DTEnable */ 0, /* DTHInverte */ 0 ); /* DTLInverte */ PWMC_SetPeriod(PWM, CHANNEL_PWM_LED2, MAX_DUTY_CYCLE); PWMC_SetDutyCycle(PWM, CHANNEL_PWM_LED2, MIN_DUTY_CYCLE); /* Set synchronous channels, update mode = 2 */ PWMC_ConfigureSyncChannel(PWM, (1 << CHANNEL_PWM_LED0) | (1 << CHANNEL_PWM_LED1) | (1 << CHANNEL_PWM_LED2), PWM_SCM_UPDM_MODE2, // (PWMC) Automatic write of data and automatic trigger of the update 0, 0); /* Set Synchronous channel update period value */ PWMC_SetSyncChannelUpdatePeriod(PWM, PWM_SCUP_UPR(0xF)); /* Configure interrupt for PDC transfer */ NVIC_DisableIRQ(PWM_IRQn); NVIC_ClearPendingIRQ(PWM_IRQn); NVIC_SetPriority(PWM_IRQn, 0); NVIC_EnableIRQ(PWM_IRQn); PWMC_EnableIt(PWM, 0, PWM_IER2_ENDTX); /* Set override value to 1 on PWMH0, others is 0. */ PWMC_SetOverrideValue(PWM, PWM_OOV_OOVH0); /* Fill duty cycle buffer for channel #0, #1 and #2 */ /* For Channel #0, #1, #2 duty cycle are from MIN_DUTY_CYCLE to MAX_DUTY_CYCLE */ for (i = 0; i < DUTY_BUFFER_LENGTH/3; i++) { dutyBuffer[i*3] = (i + MIN_DUTY_CYCLE); dutyBuffer[i*3+1] = (i + MIN_DUTY_CYCLE); dutyBuffer[i*3+2] = (i + MIN_DUTY_CYCLE); } /* Define the PDC transfer */ PWMC_WriteBuffer(PWM, dutyBuffer, DUTY_BUFFER_LENGTH); /* Enable syncronous channels by enable channel #0 */ PWMC_EnableChannel(PWM, CHANNEL_PWM_LED0); while (1) { _DisplayMenu(); key = UART_GetChar(); switch (key) { case 'u': printf("Input update period between %d to %d.\n\r", 0, PWM_SCUP_UPR_Msk); numkey = _GetNumkey2Digit(); if(numkey <= PWM_SCUP_UPR_Msk) { /* Set synchronous channel update period value */ PWMC_SetSyncChannelUpdatePeriod(PWM, numkey); printf("Done\n\r"); } else { printf("Invalid input\n\r"); } break; case 'd': printf("Input dead time for channel #0 between %d to %d.\n\r", MIN_DUTY_CYCLE, MAX_DUTY_CYCLE); numkey = _GetNumkey2Digit(); if(numkey >= MIN_DUTY_CYCLE && numkey <= MAX_DUTY_CYCLE) { /* Set synchronous channel update period value */ PWMC_SetDeadTime(PWM, CHANNEL_PWM_LED0, numkey, numkey); /* Update synchronous channel */ PWMC_SetSyncChannelUpdateUnlock(PWM); printf("Done\n\r"); } else { printf("Invalid input\n\r"); } break; case 'o': printf("0: Disable override output on channel #0\n\r"); printf("1: Enable override output on channel #0\n\r"); key = UART_GetChar(); if (key == '1') { PWMC_EnableOverrideOutput(PWM, PWM_OSSUPD_OSSUPH0 | PWM_OSSUPD_OSSUPL0, 1); printf("Done\n\r"); } else if (key == '0') { PWMC_DisableOverrideOutput(PWM, PWM_OSSUPD_OSSUPH0 | PWM_OSSUPD_OSSUPL0, 1); printf("Done\n\r"); } break; default: printf("Invalid input\n\r"); break; } } }