当前位置:网站首页>1. Mx6u-alpha development board (buzzer experiment)
1. Mx6u-alpha development board (buzzer experiment)
2022-07-24 20:10:00 【*Ruthless*】
List of articles
One 、 Hardware schematic analysis
BEEP control IO by SNVS_TAMPER1, When the output is low, the buzzer rings , The buzzer doesn't sound when outputting high level .
Two 、 The experimental program was written
1、 Initialize reuse
initialization SNVS_TAMPER1 This IO Reuse as GPIO5_IO01
2、 Set electrical properties
Set up SNVS_TAMPER1 This IO Electrical properties of
3、 initialization GPIO
4、 control GPIO Output high and low level
//bsp_beep.h
#ifndef __BSP_BEEP_H
#define __BSP_BEEP_H
#include "imx6ul.h"
/* Function declaration */
void beep_init(void);
void beep_switch(int status);
#endif
//bsp_beep.c
#include "bsp_beep.h"
void beep_init(void)
{
// initialization IO Reuse , Reuse as GPIO5_IO01
IOMUXC_SetPinMux(IOMUXC_SNVS_SNVS_TAMPER1_GPIO5_IO01,0);
// To configure GPIO1_IO03 Of IO attribute
IOMUXC_SetPinConfig(IOMUXC_SNVS_SNVS_TAMPER1_GPIO5_IO01,0X10B0);
// initialization GPIO,GPIO5_IO01 Set as output
GPIO5->GDIR |= (1 << 1);
// Set up GPIO5_IO01 Output high level , Turn off the buzzer
GPIO5->DR |= (1 << 1);
}
void beep_switch(int status)
{
if(status == ON)
GPIO5->DR &= ~(1 << 1); /* Turn on the buzzer */
else if(status == OFF)
GPIO5->DR |= (1 << 1); /* Turn off the buzzer */
}
//main.c
#include "bsp_clk.h"
#include "bsp_delay.h"
#include "bsp_led.h"
#include "bsp_beep.h"
int main(void)
{
clk_enable(); /* Enable all clocks */
led_init(); /* initialization led */
beep_init(); /* initialization beep */
while(1)
{
/* open LED0 And buzzer */
led_switch(LED0,ON);
beep_switch(ON);
delay(500);
/* close LED0 And buzzer */
led_switch(LED0,OFF);
beep_switch(OFF);
delay(500);
}
return 0;
}
Just change TARGET、INCDIRS、SRCDIRS that will do
CROSS_COMPILE ?= arm-linux-gnueabihf-
TARGET ?= beep
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
INCDIRS := imx6ul \
bsp/clk \
bsp/led \
bsp/delay \
bsp/beep
SRCDIRS := project \
bsp/clk \
bsp/led \
bsp/delay \
bsp/beep
INCLUDE := $(patsubst %, -I %, $(INCDIRS))
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
SFILENDIR := $(notdir $(SFILES))
CFILENDIR := $(notdir $(CFILES))
SOBJS := $(patsubst %, obj/%, $(SFILENDIR:.S=.o))
COBJS := $(patsubst %, obj/%, $(CFILENDIR:.c=.o))
OBJS := $(SOBJS) $(COBJS)
VPATH := $(SRCDIRS)
.PHONY: clean
$(TARGET).bin : $(OBJS)
$(LD) -Timx6ul.lds -o $(TARGET).elf $^
$(OBJCOPY) -O binary -S $(TARGET).elf [email protected]
$(OBJDUMP) -D -m arm $(TARGET).elf > $(TARGET).dis
$(SOBJS) : obj/%.o : %.S
$(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o [email protected] $<
$(COBJS) : obj/%.o : %.c
$(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o [email protected] $<
clean:
rm -rf $(TARGET).elf $(TARGET).dis $(TARGET).bin $(COBJS) $(SOBJS)
3、 ... and 、 Experimental phenomena
LED Buzzer sounds when the light is on ,LED The buzzer does not sound when the light is off
边栏推荐
- Istio II traffic hijacking process
- Inconsistent time
- Are network security and data security indistinguishable? Why is data security important?
- In the era of new knowledge economy, who is producing knowledge?
- [German flavor] safety: how to provide more protection for pedestrians
- Huawei set up login with account and password
- (posted) differences and connections between beanfactory and factorybean
- Classic interview questions of interface testing: what is the difference between session, cookie and token?
- The difference between delete, truncate and drop in MySQL
- A circle is displayed and can be moved
猜你喜欢

vlan技术

147 set whether to cache by using the routing meta information - use of include and exclude - use of activated and deactivated
![2019 Hangdian multi school first 6581 vacation [thinking]](/img/38/5a74d3ef346d6801f9da8fd3a4b23a.png)
2019 Hangdian multi school first 6581 vacation [thinking]

Istio一之Envoy工作原理

Todolist case

Introduction to fastdfs high availability

Batch download files from the server to the local

C# 窗体应用TreeView控件使用

Pix2seq: Google brain proposes a unified interface for CV tasks!

【LeetCode】1184. 公交站间的距离
随机推荐
YouTube "label products" pilot project launched
纯C实现----------尼科彻斯定理
Work notes - some problems encountered when using jest
Maya coffee machine modeling
01 | 开篇词:手把手教你搭建一个博客网站
2019 Hangdian multi school first 6581 vacation [thinking]
How to integrate Kata in kubernetes cluster
[German flavor] safety: how to provide more protection for pedestrians
Talk about your transformation test development process
2019 Hangzhou Electric Multi School Game 9 6684 Rikka with game [game question]
Flink window & time principle
微服务架构 | 服务监控与隔离 - [Sentinel] TBC...
The U.S. economy continues to be weak, and Microsoft has frozen recruitment: the cloud business and security software departments have become the hardest hit
Redisgraph graphic database multi activity design scheme
Working principle of envy of istio I
Leetcode 560 and the subarray of K (with negative numbers, one-time traversal prefix and), leetcode 438 find all alphabetic ectopic words in the string (optimized sliding window), leetcode 141 circula
[training Day8] series [matrix multiplication]
Pure C implementation -------- Nicolas theorem
【德味】安全:如何为行人提供更多保护
Leetcode 48 rotating image (horizontal + main diagonal), leetcode 221 maximum square (dynamic programming DP indicates the answer value with ij as the lower right corner), leetcode 240 searching two-d