Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 00008 DigitalOut IRD1(PA_6); 00009 DigitalOut IRD2(PA_7); 00010 DigitalOut linksR(PC_0); 00011 DigitalOut linksS(PC_1); 00012 DigitalOut rechtsR(PC_2); 00013 DigitalOut rechtsS(PC_3); 00014 DigitalIn sens1(PC_8); 00015 DigitalIn sens2(PC_9); 00016 00017 void TIM6_IRQHandler(void) 00018 { 00019 IRD1=!IRD1; 00020 IRD2=!IRD2; 00021 TIM6->SR=0; 00022 HAL_NVIC_ClearPendingIRQ(TIM6_IRQn); 00023 } 00024 00025 /* TIM6 init function */ 00026 void TIM6_Init(void) 00027 { 00028 RCC->APB1ENR|=0b10000; //Clock Enable 00029 TIM6->PSC=0; //Prescaler 32MHz 00030 TIM6->ARR=416; //Autoreload 5000*100µs = 0,5s 00031 TIM6->DIER=1; //UIE = 1 (Update Interrupt Enable) 00032 TIM6->SR=0; //UIF =0 (Update Interrupt Flag) 00033 TIM6->CR1=1; //CEN=1 (Counter Enable) 00034 /* TIM6_IRQn interrupt configuration */ 00035 NVIC_SetVector(TIM6_IRQn, (uint32_t)&TIM6_IRQHandler); 00036 HAL_NVIC_EnableIRQ(TIM6_IRQn); 00037 00038 } 00039 00040 00041 00042 00043 int main() 00044 { 00045 00046 TIM6_Init(); 00047 sens1.mode(PullUp); 00048 sens2.mode(PullUp); 00049 while (true) { 00050 linksS=sens1; 00051 linksR=!linksS; 00052 rechtsS=sens2; 00053 rechtsR=!rechtsS; 00054 00055 } 00056 }
Generated on Wed Jul 20 2022 04:21:54 by
1.7.2