资源简介
OLED屏的使用帮助及基于c51 k60 x128的参考程序

代码片段和文件信息
/*
* 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 2014-02-26 20:11 原文件\
目录 0 2014-02-26 20:10 原文件\OLED-K60\
文件 28370 2014-02-26 20:10 原文件\OLED-K60\DEMOK_Kinetis_GPIO_Example.dep
文件 52169 2013-01-13 23:29 原文件\OLED-K60\DEMOK_Kinetis_GPIO_Example.ewd
文件 52981 2013-01-09 19:03 原文件\OLED-K60\DEMOK_Kinetis_GPIO_Example.ewp
文件 180 2012-11-07 15:35 原文件\OLED-K60\DEMOK_Kinetis_GPIO_Example.eww
目录 0 2013-01-24 21:51 原文件\OLED-K60\Debug\
目录 0 2014-02-26 20:10 原文件\OLED-K60\Debug\Exe\
文件 23095 2014-02-26 20:10 原文件\OLED-K60\Debug\Exe\DEMOK_Kinetis_GPIO_Example.hex
文件 184984 2014-02-26 20:10 原文件\OLED-K60\Debug\Exe\DEMOK_Kinetis_GPIO_Example.out
目录 0 2014-02-26 20:33 原文件\OLED-K60\Debug\List\
目录 0 2014-02-26 20:10 原文件\OLED-K60\Debug\Obj\
文件 1763 2014-02-26 20:10 原文件\OLED-K60\Debug\Obj\DEMOK_Kinetis_GPIO_Example.pbd
文件 22900 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\FTM.o
文件 70692 2013-01-13 23:19 原文件\OLED-K60\Debug\Obj\LQ12864.o
文件 10000 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\PIT.o
文件 27632 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\adc.o
文件 12072 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\alloc.o
文件 17536 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\arm_cm4.o
文件 8680 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\assert.o
文件 1920 2012-11-10 22:21 原文件\OLED-K60\Debug\Obj\crt0.o
文件 9580 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\delay.o
文件 8712 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\exti.o
文件 18628 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\gpio.o
文件 10664 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\io.o
文件 3908 2013-01-09 19:02 原文件\OLED-K60\Debug\Obj\isr.o
文件 7672 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\lptmr.o
文件 8720 2014-02-26 20:10 原文件\OLED-K60\Debug\Obj\main.o
文件 14104 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\mcg.o
文件 11520 2013-01-09 19:02 原文件\OLED-K60\Debug\Obj\memtest.o
文件 26304 2013-01-13 23:14 原文件\OLED-K60\Debug\Obj\printf.o
............此处省略977个文件信息
- 上一篇:VC五子棋源代码 想要的速度下哦 多线程
- 下一篇:NIITsm3在线考试切图有答案
相关资源
- STC8951系列单片机中方指南
- proteus仿真 AT89C51输出各种波形
- 基于AT89C51的数据采集系统设计新方法
- C51单片机汇编指令查询、学习工具集
- 基于89c51的数字钟
- 基于单片机交通灯设计
- SX1280.rar
- 基于89C51计算机锁定加密键盘设计
- 基于51单片机的计算器(C51编写,有
- STM32+TMC5160代码电路图.rar
- 基于STM32F103C8单片机的晶联讯电子JL
- AT89C51+ADC0808 PROTEUS仿真
- 基于K60的线性CCD摄像头的自主循迹平
- ov7725彩色摄像头显示图像k60源码
- 单片机原理及接口技术C51编程张毅刚
- 基于AT89C51的十字路口交通灯设计pro
- 单片机原理及接口技术C51编程
- at89c51单片机外文翻译
- 单片机原理及接口技术C51编程高清P
- 基于C51的电子琴设计
- K60驱动OLED液晶屏程序
- 实现飞思卡尔两轮智能车的直立芯片
- keilc51源代码
- 在C51中变量的空间分配几个方法
- 初学C51的一些误区
- 单片机初学者学习C51时的一些误区和
- Philips 80C51MX
- 16x128LED点阵显示屏横向滚动.zip
- 12bit流水线ADC电路整体电路原理图-c
- 0.96OLED_C51系列_IIC应答_例程
评论
共有 条评论