酒店

手把手教你打造最简STM32F0USB开发板

  • 来源:面包芯语
  • 时间:2023-07-27 21:36:53

#include "stm32f0xx.h"

int main(void)

{


(资料图片仅供参考)

RCC->AHBENR |= RCC_AHBENR_GPIOAEN;// enable GPIO port A & B clock

GPIOA->MODER = GPIO_MODER_MODER8_0; // PA8 as general output (LED)

RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // enable basic timer 6

TIM6->PSC = 9999; // prescaler

TIM6->ARR = 399; // auto reload value

TIM6->CR1 = TIM_CR1_URS|TIM_CR1_CEN; // start counter

while(1)

{

static char a=0;

if(TIM6->SR & TIM_SR_UIF) // check if overflow

{

TIM6->SR &= ~TIM_SR_UIF; // clear flag

if(a==0)

{

GPIOA->BSRR = (1<<8);

a=1;

}

else

{

GPIOA->BRR = (1<<8);

a=0;

}

}

}

}

E:\arm\test072\mini>arm-none-eabi-objdump -S mini.o

mini.o: file format elf32-littlearm

Disassembly of section .text.startup:

00000000

:

0: 4b16 ldr r3, [pc, #88] ; (5c )

2: 2280 movs r2, #128 ; 0x80

4: 6959 ldr r1, [r3, #20]

6: 0292 lsls r2, r2, #10

8: 430a orrs r2, r1

a: b510 push {r4, lr}

c: 2180 movs r1, #128 ; 0x80

e: 615a str r2, [r3, #20]

24: 851a strh r2, [r3, #40] ; 0x28

26: 2290 movs r2, #144 ; 0x90

28: 32ff adds r2, #255 ; 0xff

2a: 62da str r2, [r3, #44] ; 0x2c

完整代码请点击阅读原文

50: 6184 str r4, [r0, #24]

52: 1c0a adds r2, r1, #0

54: e7ee b.n 34

56: 8504 strh r4, [r0, #40] ; 0x28

58: 2200 movs r2, #0

5a: e7eb b.n 34

5c: 40021000 .word 0x40021000

60: 40001000 .word 0x40001000

64: 0000270f .word 0x0000270f

68: 00000000 .word 0x00000000

E:\arm\test072\mini>arm-none-eabi-nm mini.o

00000000 b a.4686

00000000 T main

/*

*****************************************************************************

**File : stm32_flash.ld

*****************************************************************************

*/

/* Entry Point */

ENTRY(Reset_Handler)

/* Highest address of the user mode stack */

_estack = 0x20003FFF; /* end of RAM */

完整代码请点击阅读原文

/DISCARD/ :

{

libc.a ( * )

libm.a ( * )

libgcc.a ( * )

}

.ARM.attributes 0 : { *(.ARM.attributes) }

}

E:\arm\test072\mini>arm-none-eabi-objdump -S mini.elf

mini.elf: file format elf32-littlearm

Disassembly of section .text:

08000000

:

8000000: 4b16 ldr r3, [pc, #88] ; (800005c )

8000002: 2280 movs r2, #128 ; 0x80

8000004: 6959 ldr r1, [r3, #20]

8000006: 0292 lsls r2, r2, #10

8000008: 430a orrs r2, r1

800000a: b510 push {r4, lr}

完整代码请点击阅读原文

8000050: 6184 str r4, [r0, #24]

8000052: 1c0a adds r2, r1, #0

8000054: e7ee b.n 8000034

8000056: 8504 strh r4, [r0, #40] ; 0x28

8000058: 2200 movs r2, #0

800005a: e7eb b.n 8000034

800005c: 40021000 .word 0x40021000

8000060: 40001000 .word 0x40001000

8000064: 0000270f .word 0x0000270f

8000068: 20000000 .word 0x20000000

/**

******************************************************************************

* @file startup_stm32f072.s

* @author MCD Application Team

******************************************************************************

*/

.syntax unified

.cpu cortex-m0

.fpu softvfp

.thumb

.global g_pfnVectors

.global Default_Handler

完整代码请点击阅读原文

.weak USART2_IRQHandler

.thumb_set USART2_IRQHandler,Default_Handler

.weak USART3_4_IRQHandler

.thumb_set USART3_4_IRQHandler,Default_Handler

.weak CEC_CAN_IRQHandler

.thumb_set CEC_CAN_IRQHandler,Default_Handler

.weak USB_IRQHandler

.thumb_set USB_IRQHandler,Default_Handler

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

/**

* @file app.c

*/

/* Includes ------------------------------------------------------------------*/

#include"usbd_msc_core.h"

#include"usbd_usr.h"

USB_CORE_HANDLEUSB_Device_dev ;

int main(void)

{

USBD_Init(&USB_Device_dev,

&USR_desc,

&USBD_MSC_cb,

&USR_cb);

while (1)

{

}

}

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t* file, uint32_t line)

{

while (1)

{}

}

#endif

/**

******************************************************************************

* @file usbd_desc.c

* @authorMCD Application Team

* @version V1.0.0

* @date 31-January-2014

* @brief This file provides the USBD descriptors and string formating method.

******************************************************************************

* @attention

*

*

© COPYRIGHT 2014 STMicroelectronics

*

* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");

* You may not use this file except in compliance with the License.

完整代码请点击阅读原文

value = value << 4;

pbuf[ 2* idx + 1] = 0;

}

}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

/**

******************************************************************************

* @file usbd_storage_msd.c

* @authorMCD application Team

* @version V1.0.0

* @date 31-January-2014

* @brief This file provides the disk operations functions.

完整代码请点击阅读原文

{

return (STORAGE_LUN_NBR - 1);

}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

文中提到的相关附件及完整代码请点击阅读原文浏览。

本文来源网络,免费传达知识,版权归原作者所有。如涉及作品版权问题,请联系我进行删除。

往期推荐

《嵌入式Linux驱动大全》

关键词:

推荐内容

Copyright @  2015-2022 青年旅行网版权所有  

备案号:皖ICP备2022009963号-20

  

联系邮箱:39 60 291 42@qq.com