コード例 #1
0
/**************************实现函数********************************************
*函数原型:		void MPU6050_Check()
*功  能:	  检测IIC总线上的MPU6050是否存在
*******************************************************************************/
void MPU6050_Check(void)
{
	switch(MPU6050_testConnection()) {
	case 0:
		Q_printf("MPU6050 not found...\r\n");
		break;
	case 1:
		Q_printf("MPU6050 check success...\r\n");
		break;
	}
}
コード例 #2
0
ファイル: mapfile.c プロジェクト: stuaxo/dosemu2
static void *alias_mapping_file(int cap, void *target, size_t mapsize, int protect, void *source)
{
  int fixed = (cap & MAPPING_FIXED) ? MAP_FIXED : 0;
  off_t offs = (char *)source - mpool;
  void *addr;

  if (offs < 0 || (offs+mapsize >= (mpool_numpages*PAGE_SIZE))) {
    Q_printf("MAPPING: alias_map to address outside of temp file\n");
    errno = EINVAL;
    return MAP_FAILED;
  }
  addr =  mmap(target, mapsize, protect, MAP_SHARED | fixed, tmpfile_fd, offs);
  if (addr == MAP_FAILED) {
    addr =  mmap(target, mapsize, protect & ~PROT_EXEC, MAP_SHARED | fixed,
		 tmpfile_fd, offs);
    if (addr != MAP_FAILED)
      mprotect(addr, mapsize, protect);
  }
#if 1
  Q_printf("MAPPING: alias_map, fileoffs %llx to %p size %zx, result %p\n",
			(long long)offs, target, mapsize, addr);
#endif
  return addr;
}
コード例 #3
0
ファイル: BT.c プロジェクト: jcook/crazepony-firmware-none
//轮询蓝牙模块所有可能的波特率,获取当前波特率
//并且配置其波特率为115200,
u32 BT_Scan_Buad(void)
{
	//蓝牙波特率率表,将9600(默认波特率)和230400(hm-06遗留bug)放到最前
	//115200(将要配置的波特率)放到最后
	static u32 bandsel[9] = {230400,9600,1200,2400,4800,19200,38400,57600,115200};
	u8 i;

	for(i=0; i<9; i++) {
		UART1_init(SysClock,bandsel[i]);
		Uart1SendaBTCmd(ATcmdAsk);
		if(CmdJudgement(ATcmdAnswer) == true) {
			Q_printf("BT Scan %d\r\n", bandsel[i]);
			return bandsel[i];
		}
	}

	return 0;
}
コード例 #4
0
ファイル: mapfile.c プロジェクト: stuaxo/dosemu2
/*
 * NOTE: DPMI relies on realloc_mapping() _not_ changing the address ('addr'),
 *       when shrinking the memory region.
 */
static void *realloc_mapping_file(int cap, void *addr, size_t oldsize, size_t newsize)
{
  Q__printf("MAPPING: realloc, cap=%s, addr=%p, oldsize=%zx, newsize=%zx\n",
	cap, addr, oldsize, newsize);
  if (cap & (MAPPING_EMS | MAPPING_DPMI)) {
    int size = smget_area_size(&pgmpool, addr);
    void *addr_;

    if (!size || size != oldsize) return (void *)-1;
    if (size == newsize) return addr;
		/* NOTE: smrealloc() does not change addr,
		 *       when shrinking the memory region.
		 */
    addr_ = smrealloc(&pgmpool, addr, newsize);
    if (!addr_) {
      Q_printf("MAPPING: pgrealloc(0x%p,0x%zx,) failed\n",
		addr, newsize);
      return (void *)-1;
    }
    return addr_;
  }
  return (void *)-1;
}
コード例 #5
0
ファイル: BT.c プロジェクト: jcook/crazepony-firmware-none
/********************************************
              写蓝牙参数函数
********************************************/
void BT_ATcmdWrite(void)
{
	u8 i;
	static	u32 BT_CurBaud;
	static u32 bandsel[9] = {230400,9600,1200,2400,4800,19200,38400,57600,115200};

	Uart1SendaBTCmd(ATcmdAsk);
	if(CmdJudgement(ATcmdAnswer) == true) {
		//HM-11模块已经是115200波特率,无需配置
		return ;
	}

	Q_printf("BT baund check and init begin. Q_printf is useless.\r\n\r\n");

	BT_CurBaud = BT_Scan_Buad();

	if (BT_CurBaud == 0) {
		Q_printf("BT scan buad failed!\r\n");
		goto quit;
	
	}

	//首先检测蓝牙模块的串口是否已经配置为115200
	if(BT_CurBaud != BT_BAUD_Set) {

		//蓝牙模块需要修改其名字,波特率

		//修改蓝牙的名字为Crazepony
		Uart1SendaBTCmd(ATcmdNameSet);

		//修改蓝牙波特率为115200
		Uart1SendaBTCmd(ATcmdBaudSet);

		//LED闪烁表示原来蓝牙模块是哪个波特率
		for(i=0; i<9; i++) {
			LedA_on;
			LedB_on;
			LedC_on;
			LedD_on;
			delay_ms(1000);
			LedA_off;
			LedB_off;
			LedC_off;
			LedD_off;
			delay_ms(1000);

			if(BT_CurBaud == bandsel[i]) {
				break;
			}
		}
	} else {
		//已经是115200,可以直接通信
		Q_printf("BT module baud is 115200 okay\r\n");
	}
quit:
	//最终STM32的UART波特率设置回115200
	UART1_init(SysClock, BT_BAUD_Set);

	Q_printf("\r\nBT baund check and init end.\r\n");

}
コード例 #6
0
ファイル: mapfile.c プロジェクト: stuaxo/dosemu2
static int open_mapping_f(int cap)
{
    int mapsize, estsize, padsize;

    if (cap) Q_printf("MAPPING: open, cap=%s\n",
	  decode_mapping_cap(cap));

    padsize = 4*1024;

    /* first estimate the needed size of the mapfile */
    mapsize  = HMASIZE >> 10;	/* HMA */
 				/* VGAEMU */
    mapsize += config.vgaemu_memsize ? config.vgaemu_memsize : 1024;
    mapsize += config.ems_size;	/* EMS */
    mapsize += LOWMEM_SIZE >> 10; /* Low Mem */
    estsize = mapsize;
				/* keep heap fragmentation in mind */
    mapsize += (mapsize/4 < padsize ? padsize : mapsize/4);
    mpool_numpages = mapsize / 4;
    mapsize = mpool_numpages * PAGE_SIZE; /* make sure we are page aligned */

    ftruncate(tmpfile_fd, 0);
    if (ftruncate(tmpfile_fd, mapsize) == -1) {
      if (!cap)
	error("MAPPING: cannot size temp file pool, %s\n",strerror(errno));
      discardtempfile();
      if (!cap)return 0;
      leavedos(2);
    }
    /* /dev/shm may be mounted noexec, and then mounting PROT_EXEC fails.
       However mprotect may work around this (maybe not in future kernels)
    */
    mpool = mmap(0, mapsize, PROT_READ|PROT_WRITE,
    		MAP_SHARED, tmpfile_fd, 0);
    if (mpool == MAP_FAILED ||
	mprotect(mpool, mapsize, PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
      char *err = strerror(errno);
      char s[] = "MAPPING: cannot size temp file pool, %s\n";
      discardtempfile();
      if (!cap) {
	Q_printf(s,err);
	return 0;
      }
      leavedos(2);
    }
    /* the memory pool itself can just be rw though */
    mprotect(mpool, mapsize, PROT_READ|PROT_WRITE);
    Q_printf("MAPPING: open, mpool (min %dK) is %d Kbytes at %p-%p\n",
		estsize, mapsize/1024, mpool, mpool+mapsize-1);
    sminit(&pgmpool, mpool, mapsize);

  /*
   * Now handle individual cases.
   * Don't forget that each of the below code pieces should only
   * be executed once !
   */

#if 0
  if (cap & MAPPING_OTHER) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_EMS) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_DPMI) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_VIDEO) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_VGAEMU) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_HGC) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_HMA) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_SHARED) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_INIT_HWRAM) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_INIT_LOWRAM) {
    /* none for now */
  }
#endif

  return 1;
}
コード例 #7
0
ファイル: mapfile.c プロジェクト: stuaxo/dosemu2
static void close_mapping_file(int cap)
{
  Q_printf("MAPPING: close, cap=%s\n", decode_mapping_cap(cap));
  if (cap == MAPPING_ALL && tmpfile_fd != -1) discardtempfile();
}
コード例 #8
0
ファイル: mapshm.c プロジェクト: ccarcel/dosemu2
static int open_mapping_shm(int cap)
{
  static int first =1;

  if (cap) Q_printf("MAPPING: open, cap=%s\n",
				decode_mapping_cap(cap));

  if (first) {
    void *ptr1, *ptr2 = MAP_FAILED;
    first = 0;

    /* do a test alias mapping. kernel 2.6.1 doesn't support our mremap trick */
    ptr1 = mmap(0, PAGE_SIZE, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
    if (ptr1 != MAP_FAILED) {
      ptr2 = mremap(ptr1, 0, PAGE_SIZE, MREMAP_MAYMOVE);
      munmap(ptr1, PAGE_SIZE);
      if (ptr2 != MAP_FAILED)
        munmap(ptr2, PAGE_SIZE);
    }
    if (ptr2 == MAP_FAILED) {
      Q_printf("MAPPING: not using mapshm because alias mapping does not work\n");
      if (!cap)return 0;
      leavedos(2);
    }
  }

  /*
   * Now handle individual cases.
   * Don't forget that each of the below code pieces should only
   * be executed once !
   */

#if 0
  if (cap & MAPPING_OTHER) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_EMS) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_DPMI) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_VIDEO) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_VGAEMU) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_HGC) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_HMA) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_SHARED) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_INIT_HWRAM) {
    /* none for now */
  }
#endif
#if 0
  if (cap & MAPPING_INIT_LOWRAM) {
    /* none for now */
  }
#endif

  return 1;
}
コード例 #9
0
ファイル: mapshm.c プロジェクト: ccarcel/dosemu2
static void close_mapping_shm(int cap)
{
  Q_printf("MAPPING: close, cap=%s\n", decode_mapping_cap(cap));
}