void BSP_Init() { NVIC_Configuration(); #if USING_SRAM_AS_HEAP > 0 FSMC_SRAM_Init(); #endif #if WATCHDOG_ENABLE > 0 WATCHDOG_setTimeOut(15); //如果15秒仍未启动完成,那么就复位 WATCHDOG_enable(); //调试时要屏蔽 #endif _init_alloc(HEAP_BASE, HEAP_TOP); USART1_Init(); USART2_Init(); USART3_Init(); #ifdef STM32F10X_CL UART4_Init(); UART5_Init(); #endif //STM32F10X_CL Delay_ms(10); }
int vmbuf_inflate2(struct vmbuf *inbuf, struct vmbuf *outbuf) { z_stream strm; _init_alloc(&strm); if (Z_OK != inflateInit2(&strm, 15+16)) return -1; for (;;) { strm.next_in = (uint8_t *)vmbuf_rloc(inbuf); strm.avail_in = vmbuf_ravail(inbuf); if (0 == strm.avail_in) break; vmbuf_resize_if_less(outbuf, strm.avail_in << 1); strm.next_out = (uint8_t *)vmbuf_wloc(outbuf); strm.avail_out = vmbuf_wavail(outbuf); int res = inflate(&strm, Z_NO_FLUSH); vmbuf_wseek(outbuf, vmbuf_wavail(outbuf) - strm.avail_out); if (res == Z_STREAM_END) break; if (Z_OK != res) return inflateEnd(&strm), -1; vmbuf_rseek(inbuf, vmbuf_ravail(inbuf) - strm.avail_in); } inflateEnd(&strm); return 0; }
void Main(void) { //硬件初始化 var_Init();//初始化定时器相关的参数 Port_Init();//IO端口初始化 Isr_Init();//中断初始化 Uart_Init(0,115200);//串口初始化 Uart_Select(0); _init_alloc(0x32500000,0x333fffff);//初始化堆地址:15M,使能malloc等存储分配函数 setlocale(LC_ALL,"C");//使能本地函数,如sprintf等 Timer4_Init(); lcdTest(); }
int __init(int argc, char **argv) { int ans; _error_recursion = 0; _curbrk = &end; _ctype_init(); /* init to C locale */ _init_alloc(); _exit_init(); /* must happen before exit() can be called */ _initio(NULL, NULL, NULL); ans = main(argc, argv, _environ); while (number_of_exit_functions!=0) (*_exitvector[--number_of_exit_functions])(); _terminateio(); _syscall1(SYS_exit, ans); }
void TargetInit(void) { int i; U8 key; U32 mpll_val=0; i = 2 ; //use 400M! switch ( i ) { case 0: //200 key = 12; mpll_val = (92<<12)|(4<<4)|(1); break; case 1: //300 key = 14; mpll_val = (67<<12)|(1<<4)|(1); break; case 2: //400 key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; case 3: //440!!! key = 14; mpll_val = (102<<12)|(1<<4)|(1); break; default: key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; } //init FCLK=400M, so change MPLL first ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3); ChangeClockDivider(key, 12); MMU_DisableICache(); MMU_DisableDCache(); Port_Init(); MMU_Init(); _init_alloc(0x17fe000, 0x17ff000);/*分配堆的起始地址和结束地址,4k的空间*/ Delay(0); Uart_Init(0,115200); Uart_Select(0); Uart_SendString("Board init complete.\n"); }
/* version. */ void uHALir_ReInitHeap(void) { uHAL_heap_inited = 0; #ifdef ADS_BUILD if ((void *)_init_alloc == NULL) { // Init the uHAL Heap. uHALr_InitHeap(); } else { // Reinit the C library Heap. _init_alloc(uHALiv_BaseOfMemory, uHALiv_TopOfHeap); } #else // In the SDT case we use the uHAL malloc routines // so init those. uHALr_InitHeap(); #endif }
int vmbuf_deflate_ptr2(const void *inbuf, size_t inbuf_size, struct vmbuf *outbuf, int level) { z_stream strm; _init_alloc(&strm); if (Z_OK != deflateInit2(&strm, level, Z_DEFLATED, 15+16, 8, Z_DEFAULT_STRATEGY)) return -1; int flush, res; strm.next_in = (void *)inbuf; strm.avail_in = inbuf_size; do { strm.next_out = (uint8_t *)vmbuf_wloc(outbuf); strm.avail_out = vmbuf_wavail(outbuf); flush = strm.avail_in == 0 ? Z_FINISH : Z_NO_FLUSH; if (Z_STREAM_ERROR == (res = deflate(&strm, flush))) { deflateEnd(&strm); return -1; } vmbuf_wseek(outbuf, vmbuf_wavail(outbuf) - strm.avail_out); } while (Z_STREAM_END != res); deflateEnd(&strm); return 0; }
int vmbuf_inflate_ptr(void *inbuf, size_t inbuf_size, struct vmbuf *outbuf) { z_stream strm; _init_alloc(&strm); if (Z_OK != inflateInit2(&strm, 15+16)) return -1; strm.next_in = inbuf; strm.avail_in = inbuf_size; for (;0 < strm.avail_in;) { if (0 > vmbuf_resize_if_less(outbuf, strm.avail_in << 1)) return inflateEnd(&strm), -1; strm.next_out = (uint8_t *)vmbuf_wloc(outbuf); strm.avail_out = vmbuf_wavail(outbuf); int res = inflate(&strm, Z_NO_FLUSH); vmbuf_wseek(outbuf, vmbuf_wavail(outbuf) - strm.avail_out); if (res == Z_STREAM_END) return inflateEnd(&strm), strm.avail_in == 0 ? 0 : -1; /* return error if inbuf has extra data */ if (Z_OK != res) return inflateEnd(&strm), -1; } inflateEnd(&strm); return -1; /* if we reached here, we have partial outbuf */ }
ZDBDatum::ZDBDatum(int len) { _init_alloc(len); }
ZDBDatum::ZDBDatum(const char *str) { _init_alloc(sizeof(uint32_t)+strlen(str)+1); write_str(str); }