
x
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 #define BAUD_RATE 9600 00004 00005 #define LD1_Pin GPIO_PIN_0 00006 #define LD2_Pin GPIO_PIN_7 00007 #define LD3_Pin GPIO_PIN_14 00008 00009 DigitalOut led1(LED1); 00010 DigitalOut led2(LED2); 00011 DigitalOut led3(LED3); 00012 00013 Serial pc(USBTX, USBRX); 00014 00015 int main() { 00016 pc.baud(BAUD_RATE); 00017 printf("\n"); 00018 printf("----------------------------------\n"); 00019 printf("Starting 20180421_Nucleo_blink_led\n"); 00020 printf("" __DATE__ " " __TIME__ "\n"); 00021 #if defined(MBED_MAJOR_VERSION) 00022 printf("Using \033[1;37mMbed OS %d.%d.%d\033[0m\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); 00023 #else 00024 printf("Using Mbed OS from master.\n"); 00025 #endif 00026 printf("CPU SystemCoreClock: \033[1;37m%d MHz\033[0m\n", SystemCoreClock/1000000); 00027 printf("----------------------------------\n"); 00028 00029 int number = 0; 00030 while(true) { 00031 // led1 = !led1; 00032 // wait(0.5); 00033 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET); 00034 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); 00035 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); 00036 HAL_Delay(500); 00037 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); 00038 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); 00039 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); 00040 HAL_Delay(500); 00041 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); 00042 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); 00043 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); 00044 HAL_Delay(500); 00045 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); 00046 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); 00047 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); 00048 HAL_Delay(500); 00049 printf("%d\n", ++number); 00050 } 00051 } 00052
Generated on Mon Jul 18 2022 00:09:20 by
