资源简介
本OLED程序例程包含了K60_4WIRE_SPI例程,使用keil软件开发环境,程序注释完整详细,可作为学习及参考的样本
代码片段和文件信息
/*
* File: alloc.c
* Purpose: generic malloc() and free() engine
*
* Notes: 99% of this code stolen/borrowed from the K&R C
* examples.
*
*/
#include “common.h“
#include “stdlib.h“
#pragma section = “HEAP“
/********************************************************************/
/*
* This struct forms the minimum block size which is allocated and
* also forms the linked list for the memory space used with alloc()
* and free(). It is padded so that on a 32-bit machine all malloc‘ed
* pointers are 16-byte aligned.
*/
typedef struct ALLOC_HDR
{
struct
{
struct ALLOC_HDR *ptr;
unsigned int size;
} s;
unsigned int align;
unsigned int pad;
} ALLOC_HDR;
static ALLOC_HDR base;
static ALLOC_HDR *freep = NULL;
/********************************************************************/
void
free (void *ap)
{
ALLOC_HDR *bp *p;
bp = (ALLOC_HDR *)ap - 1; /* point to block header */
for (p = freep; !((bp > p) && (bp < p->s.ptr)) ; p = p->s.ptr)
{
if ((p >= p->s.ptr) && ((bp > p) || (bp < p->s.ptr)))
{
break; /* freed block at start or end of arena */
}
}
if ((bp + bp->s.size) == p->s.ptr)
{
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
}
else
{
bp->s.ptr = p->s.ptr;
}
if ((p + p->s.size) == bp)
{
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
}
else
{
p->s.ptr = bp;
}
freep = p;
}
/********************************************************************/
void *
malloc (unsigned nbytes)
{
/* Get addresses for the HEAP start and end */
#if (defined(CW))
extern char __HEAP_START;
extern char __HEAP_END[];
#elif (defined(IAR))
char* __HEAP_START = __section_begin(“HEAP“);
char* __HEAP_END = __section_end(“HEAP“);
#endif
ALLOC_HDR *p *prevp;
unsigned nunits;
nunits = ((nbytes+sizeof(ALLOC_HDR)-1) / sizeof(ALLOC_HDR)) + 1;
if ((prevp = freep) == NULL)
{
p = (ALLOC_HDR *)__HEAP_START;
p->s.size = ( ((uint32)__HEAP_END - (uint32)__HEAP_START)
/ sizeof(ALLOC_HDR) );
p->s.ptr = &base;
base.s.ptr = p;
base.s.size = 0;
prevp = freep = &base;
}
for (p = prevp->s.ptr; ; prevp = p p = p->s.ptr)
{
if (p->s.size >= nunits)
{
if (p->s.size == nunits)
{
prevp->s.ptr = p->s.ptr;
}
else
{
p->s.size -= nunits;
p += p->s.size;
p->s.size = nunits;
}
freep = prevp;
return (void *)(p + 1);
}
if (p == freep)
return NULL;
}
}
/*******************************************
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\
文件 191 2013-05-25 16:53 K60_4WIRE_SPI\Demo_OLED.eww
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\config files\
文件 2030 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\128KB_Pflash.icf
文件 2206 2010-11-11 14:41 K60_4WIRE_SPI\build\iar\config files\128KB_Pflash_128KB_Dflash.icf
文件 2034 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\128KB_Ram.icf
文件 2030 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\256KB_Pflash.icf
文件 2214 2010-11-11 14:41 K60_4WIRE_SPI\build\iar\config files\256KB_Pflash_256KB_Dflash.icf
文件 2024 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\32KB_Ram.icf
文件 2041 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\512KB_Pflash.icf
文件 2217 2010-11-11 14:41 K60_4WIRE_SPI\build\iar\config files\64KB_Pflash_64KB_Dflash.icf
文件 2024 2010-10-27 14:30 K60_4WIRE_SPI\build\iar\config files\64KB_Ram.icf
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\hello_world\
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\Exe\
文件 195912 2014-06-26 09:42 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\Exe\hello_world_K60.out
文件 23296 2014-06-26 09:42 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\Exe\hello_world_K60.srec
目录 0 2015-07-12 11:12 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\
文件 34505 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\CRC.lst
文件 22901 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\CRC.s
文件 29979 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\HAL_SPI.lst
文件 23213 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\HAL_SPI.s
文件 31263 2014-05-04 15:25 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\Oled_Printf.lst
文件 22061 2014-05-04 15:25 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\Oled_Printf.s
文件 107529 2014-05-04 15:25 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\Oled_SSD1306.lst
文件 44249 2014-05-04 15:25 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\Oled_SSD1306.s
文件 67363 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\SPI_FLASH.lst
文件 43925 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\SPI_FLASH.s
文件 20539 2014-06-26 09:41 K60_4WIRE_SPI\build\iar\hello_world\FLASH_512KB_PFLASH\List\adc16.lst
............此处省略1077个文件信息
相关资源
- OLED程序例程(STM32_OLED(C8T6))
- 3_STC15F2K60S2仿真操作
- 基于stm32数字光强计GY-30光强采集ole
- stm32f013 OLED 屏幕和粉尘传感器串口
- 分享一个0.96的oled显示驱动,软件模拟
- HSPICE简明教程(复旦大学).pdf
- STM32F103C8T6+OLED
- STM32F103C8T6+DHT11+OLED
- Spiking Neuron Models
- stm32f103c8t6 OLED 硬件SPI
- STM32用IIC通信实现OLED显示程序代码及
- SPI读取MPU9250 9轴加速度,陀螺仪,磁
- STM32_(OLED)显示温度烟雾浓度工程
- unity2018中的spine骨骼动画运行库
- STM32+OLED驱动
- k60电机驱动程序
- OLED0.96寸 资料 驱动代码
- Hspice破解文件和方法都打包在一起
- 2014年智能车竞赛光电组程序
- oled xs128 驱动程序
- Automotive Spice 3.1官方英文版和中文版(
- 0.96OLED实现数字、汉字、字符串、图片
- STM32之间的SPI通信
- DTH11温湿度显示在IIC_OLED上,好用,自
- MSP432RTC实时时钟OLED显示
- 基于STM32F103的FM收音机 TEA5767
- MSP430G2553以4线SPI方式控制0.96寸OLED
- F407_SPI读写W25Q256.rar
- FPGA的SPI Verilog源码,读写flash芯片
- 模型检测工具spin
评论
共有 条评论