libopencm3库的使用

libopencm3是开源的cortex-m系列单片机的固件库,支持stm32、atmel、nxp等等系列单片机。

在Linux下编译需要交叉编译器gcc,从这里下载:https://launchpad.net/gcc-arm-embedded/+download,下载编译好的Linux下的版本就可以了。

解压缩,设置环境变量,使用arm-none-eabi-gcc -v命令测试一下设置是否成功。

然后是libopencm3库,从这里下载:https://github.com/libopencm3/libopencm3。

进入到libopencm3目录中,使用make直接编译,编译完成后会在lib目录下生成.a的库文件以及链接脚本。

libopencm3只是提供了一个库文件,我们还需要编写自己的main程序。libopencm3特提供了样例程序,从这里下载:https://github.com/libopencm3/libopencm3-examples。

编译样例程序之前,需要将libopencm3整个目录拷贝到libopencm3-examples目录下。

任意编译一个样例程序试试,例如进入到libopencm3-examples/examples/stm32/f4/stm32f4-discovery/button目录中,然后make。编译完成后最终会生成button.elf文件。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Using FreeRTOS and libopencm3 instead of the Arduino software environment, this book will help you develop multi-tasking applications that go beyond Arduino norms. In addition to the usual peripherals found in the typical Arduino device, the STM32 device includes a USB controller, RTC (Real Time Clock), DMA (Direct Memory Access controller), CAN bus and more. Each chapter contains clear explanations of the STM32 hardware capabilities to help get you started with the device, including GPIO and several other ST Microelectronics peripherals like USB and CAN bus controller. You’ll learn how to download and set up the libopencm3 + FreeRTOS development environment, using GCC. With everything set up, you’ll leverage FreeRTOS to create tasks, queues, and mutexes. You’ll also learn to work with the I2C bus to add GPIO using the PCF8574 chip. And how to create PWM output for RC control using hardware timers. You'll be introduced to new concepts that are necessary to master the STM32, such as how to extend code with GCC overlays using an external Winbond ?W25Q32 flash chip. Your knowledge is tested at the end of each chapter with exercises. Upon completing this book, you’ll be ready to work with any of the devices in the STM32 family. Beginning STM32 provides the professional, student, or hobbyist a way to learn about ARM without costing an arm! What You'll Learn Initialize and use the libopencm3 drivers and handle interrupts Use DMA to drive a SPI based OLED displaying an analog meter Read PWM from an RC control using hardware timers Who This Book Is For Experienced embedded engineers, students, hobbyists and makers wishing to explore the ARM architecture, going beyond Arduino limits.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值