예제 #1
0
/** Read block from file located on a FAT file system.
 *
 * @param block		Pointer to a block pointer for storing result.
 * @param bs		Buffer holding the boot sector of the file system.
 * @param service_id	Service ID handle of the file system.
 * @param fcl		First cluster used by the file. Can be zero if the file
 *			is empty.
 * @param clp		If not NULL, address where the cluster containing bn
 *			will be stored.
 *			stored
 * @param bn		Block number.
 * @param flags		Flags passed to libblock.
 *
 * @return		EOK on success or a negative error code.
 */
int
_fat_block_get(block_t **block, fat_bs_t *bs, service_id_t service_id,
    fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
{
	uint32_t clusters;
	uint32_t max_clusters;
	fat_cluster_t c;
	int rc;

	/*
	 * This function can only operate on non-zero length files.
	 */
	if (fcl == FAT_CLST_RES0)
		return ELIMIT;

	if (!FAT_IS_FAT32(bs) && fcl == FAT_CLST_ROOT) {
		/* root directory special case */
		assert(bn < RDS(bs));
		rc = block_get(block, service_id,
		    RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags);
		return rc;
	}

	max_clusters = bn / SPC(bs);
	rc = fat_cluster_walk(bs, service_id, fcl, &c, &clusters, max_clusters);
	if (rc != EOK)
		return rc;
	assert(clusters == max_clusters);

	rc = block_get(block, service_id, CLBN2PBN(bs, c, bn), flags);

	if (clp)
		*clp = c;

	return rc;
}
예제 #2
0
파일: rds.cpp 프로젝트: f32c/arduino
/* FM antenna test
 * Tune FM radio to 107.9 MHz
 * Bring ULX3S within 1 m distance of radio antenna
 * You should hear silence.
 * RDS display should show: "TEST1234"
 * RDS long message (optional on some radios): "@ABCDEFGHIJ.."
 */
 
#include <RDS.h>

RDS rds = RDS();

uint16_t pi = 0xCAFE;
char ps[9] = "TEST1234";
char rt[65] = "ABCDEFGH";

void rds_init() {
  int i;
  for(i = 0; i < sizeof(rt)-1; i++)
    rt[i] = '@'+i; // ascii map
  /* Setup initial RDS text */
  rds.pi(pi); // station numeric ID
  rds.stereo(0); // 0-Inform over RDS that we send Mono, 1-Stereo
  rds.ta(0);  // 0-No, 1-Traffice Announcements
  rds.ps(ps); // 8-char text, displayed as station name
  rds.rt(rt); // 64-char text, not every radio displays it
  rds.Hz(107900000); // Hz carrier wave frequency
  rds.length(260); // bytes message length (260 default)
}