随笔分类 -  stm32

摘要:1、初始化I2C配置注:除了最后的HAL_I2C_EnableListen_IT()函数,其他代码都可以用STM32CubeMX自动生成参考代码: 1 static void MX_I2C1_Init(void) 2 { 3 hi2c1.Instance = I2C1; // 配置I2C1 4 hi 阅读全文
posted @ 2025-12-09 01:27 荒原狼的技术博客 阅读(349) 评论(0) 推荐(0)
摘要:测试例程:定义一个256字节的buffer用来存放I2C从机的数据,默认赋初值0-255,然后通过中断的方式实现I2C数据读写。示例代码如下: 1 #include "stm32f10x.h" 2 #include "stm32f10x_gpio.h" 3 #include "stm32f10x_r 阅读全文
posted @ 2025-12-09 01:19 荒原狼的技术博客 阅读(28) 评论(0) 推荐(0)
摘要:一、从机双地址,在回调函数中获取主机访问的地址: void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *I2cHandle) { uint16_t slaveaddrcode = I2C_GET_ADDR_MATCH(I2cHandle); prin 阅读全文
posted @ 2025-12-04 01:20 荒原狼的技术博客 阅读(59) 评论(0) 推荐(0)
摘要:3. Packed pixel streams The packed pixel stream (PPS) packets are long packets used to transmit RGB image data formatted as pixels to a video mode dis 阅读全文
posted @ 2022-05-26 19:30 荒原狼的技术博客 阅读(120) 评论(0) 推荐(0)
摘要:在一个项目中,使用C语言,首先在一个 A文件中定义了一些全局变量,并赋初值,并在 B文件里引用,并在一个函数中重新赋值。在main函数的起始处中调用该赋值函数,发现并没有被重新赋值。 一般情况下,在中断中使用的全局变量必须要 volatile 修饰,或者一些 IO 口变量必须要 volatile 修 阅读全文
posted @ 2022-05-26 16:28 荒原狼的技术博客 阅读(105) 评论(0) 推荐(0)
摘要:STM32 在keil下进行strtol函数的功能测试 源码: void test_str2num_strtol(void) { int a; printf("\r\n\r\n0x1234 = %d,",strtol("0x1234",NULL,0)); printf("\r\n1234 = %d, 阅读全文
posted @ 2019-12-27 17:33 荒原狼的技术博客 阅读(147) 评论(0) 推荐(0)
摘要:STM32 在keil 下进行 atoi 函数功能测试: 源码: void test_str2num(void) { int a; printf("\r\n\r\n0x1234 = %d,",atoi("0x1234")); printf("\r\n0x1234 = %d,",atoi("0x123 阅读全文
posted @ 2019-12-27 17:08 荒原狼的技术博客 阅读(153) 评论(0) 推荐(0)
摘要:源码: void test_str2num(void) { printf("\r\n\r\nint is %d",sizeof(int)); printf("\r\nlong int is %d",sizeof(long int)); printf("\r\nlong long int is %d" 阅读全文
posted @ 2019-12-27 16:29 荒原狼的技术博客 阅读(266) 评论(0) 推荐(0)
摘要:源程序如下: i = 0x12345678; printf("\r\ni = 0x%X,",i); printf("addri = 0x%X,",&i); printf("\r\naddru8i = 0x%X,",(u8*)(&i)); printf("u8i = 0x%X,",*((u8*)(&i 阅读全文
posted @ 2019-12-25 16:46 荒原狼的技术博客 阅读(57) 评论(0) 推荐(0)
摘要:查了下数据手册,里面有这么一句话:The input data register (GPIOx_IDR) captures the data present on the I/O pin at every AHB1 clock cycle. 在另外一个手册里,有这么一句话:The written d 阅读全文
posted @ 2019-12-24 19:58 荒原狼的技术博客 阅读(372) 评论(0) 推荐(0)
摘要:首先要配置串口时钟: // USART1 clock enable RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); 然后再配置端口,在配置串口,再 阅读全文
posted @ 2018-09-02 18:25 荒原狼的技术博客 阅读(177) 评论(0) 推荐(0)