Merge pull request #77 from Hoernchen/master

important stuff
This commit is contained in:
Michael Ossmann
2013-06-11 10:19:04 -07:00
8 changed files with 30 additions and 14 deletions

View File

@ -32,6 +32,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules)
if(MSVC) if(MSVC)
include_directories(getopt) include_directories(getopt)
add_definitions(/D _CRT_SECURE_NO_WARNINGS)
else() else()
add_definitions(-Wall) add_definitions(-Wall)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")

View File

@ -31,7 +31,11 @@
#include <stdint.h> #include <stdint.h>
#ifdef _MSC_VER #ifdef _MSC_VER
typedef int ssize_t; #ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#endif #endif
/* input file shouldn't be any longer than this */ /* input file shouldn't be any longer than this */
#define MAX_XSVF_LENGTH 0x10000 #define MAX_XSVF_LENGTH 0x10000

View File

@ -64,7 +64,7 @@ int parse_int(char* s, uint16_t* const value) {
s_end = s; s_end = s;
long_value = strtol(s, &s_end, base); long_value = strtol(s, &s_end, base);
if( (s != s_end) && (*s_end == 0) ) { if( (s != s_end) && (*s_end == 0) ) {
*value = long_value; *value = (uint16_t)long_value;
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} else { } else {
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;
@ -73,7 +73,7 @@ int parse_int(char* s, uint16_t* const value) {
int dump_register(hackrf_device* device, const uint16_t register_number) { int dump_register(hackrf_device* device, const uint16_t register_number) {
uint16_t register_value; uint16_t register_value;
int result = hackrf_max2837_read(device, register_number, &register_value); int result = hackrf_max2837_read(device, (uint8_t)register_number, &register_value);
if( result == HACKRF_SUCCESS ) { if( result == HACKRF_SUCCESS ) {
printf("[%2d] -> 0x%03x\n", register_number, register_value); printf("[%2d] -> 0x%03x\n", register_number, register_value);
@ -104,7 +104,7 @@ int write_register(
const uint16_t register_value const uint16_t register_value
) { ) {
int result = HACKRF_SUCCESS; int result = HACKRF_SUCCESS;
result = hackrf_max2837_write(device, register_number, register_value); result = hackrf_max2837_write(device, (uint8_t)register_number, register_value);
if( result == HACKRF_SUCCESS ) { if( result == HACKRF_SUCCESS ) {
printf("0x%03x -> [%2d]\n", register_value, register_number); printf("0x%03x -> [%2d]\n", register_value, register_number);

View File

@ -65,7 +65,7 @@ int parse_int(char* s, uint16_t* const value) {
s_end = s; s_end = s;
long_value = strtol(s, &s_end, base); long_value = strtol(s, &s_end, base);
if( (s != s_end) && (*s_end == 0) ) { if( (s != s_end) && (*s_end == 0) ) {
*value = long_value; *value = (uint16_t)long_value;
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} else { } else {
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;
@ -74,7 +74,7 @@ int parse_int(char* s, uint16_t* const value) {
int dump_register(hackrf_device* device, const uint16_t register_number) { int dump_register(hackrf_device* device, const uint16_t register_number) {
uint16_t register_value; uint16_t register_value;
int result = hackrf_rffc5071_read(device, register_number, &register_value); int result = hackrf_rffc5071_read(device, (uint8_t)register_number, &register_value);
if( result == HACKRF_SUCCESS ) { if( result == HACKRF_SUCCESS ) {
printf("[%2d] -> 0x%03x\n", register_number, register_value); printf("[%2d] -> 0x%03x\n", register_number, register_value);
@ -105,7 +105,7 @@ int write_register(
const uint16_t register_value const uint16_t register_value
) { ) {
int result = HACKRF_SUCCESS; int result = HACKRF_SUCCESS;
result = hackrf_rffc5071_write(device, register_number, register_value); result = hackrf_rffc5071_write(device, (uint8_t)register_number, register_value);
if( result == HACKRF_SUCCESS ) { if( result == HACKRF_SUCCESS ) {
printf("0x%03x -> [%2d]\n", register_value, register_number); printf("0x%03x -> [%2d]\n", register_value, register_number);

View File

@ -49,7 +49,7 @@ int parse_int(char* const s, uint16_t* const value) {
char* s_end = s; char* s_end = s;
const long long_value = strtol(s, &s_end, 10); const long long_value = strtol(s, &s_end, 10);
if( (s != s_end) && (*s_end == 0) ) { if( (s != s_end) && (*s_end == 0) ) {
*value = long_value; *value = (uint16_t)long_value;
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} else { } else {
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;

View File

@ -36,7 +36,11 @@ typedef int bool;
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
typedef int ssize_t; #ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#endif #endif
/* 8 Mbit flash */ /* 8 Mbit flash */

View File

@ -43,7 +43,13 @@ typedef int bool;
#include <windows.h> #include <windows.h>
#ifdef _MSC_VER #ifdef _MSC_VER
typedef int ssize_t;
#ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
#define strtoull _strtoui64 #define strtoull _strtoui64
#define snprintf _snprintf #define snprintf _snprintf
@ -216,7 +222,7 @@ int parse_u32(char* s, uint32_t* const value) {
s_end = s; s_end = s;
ulong_value = strtoul(s, &s_end, base); ulong_value = strtoul(s, &s_end, base);
if( (s != s_end) && (*s_end == 0) ) { if( (s != s_end) && (*s_end == 0) ) {
*value = ulong_value; *value = (uint32_t)ulong_value;
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} else { } else {
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;
@ -261,7 +267,7 @@ int rx_callback(hackrf_transfer* transfer) {
bytes_to_write = transfer->valid_length; bytes_to_write = transfer->valid_length;
if (limit_num_samples) { if (limit_num_samples) {
if (bytes_to_write >= bytes_to_xfer) { if (bytes_to_write >= bytes_to_xfer) {
bytes_to_write = bytes_to_xfer; bytes_to_write = (int)bytes_to_xfer;
} }
bytes_to_xfer -= bytes_to_write; bytes_to_xfer -= bytes_to_write;
} }
@ -293,7 +299,7 @@ int tx_callback(hackrf_transfer* transfer) {
* In this condition, we probably tx some of the previous * In this condition, we probably tx some of the previous
* buffer contents at the end. :-( * buffer contents at the end. :-(
*/ */
bytes_to_read = bytes_to_xfer; bytes_to_read = (int)bytes_to_xfer;
} }
bytes_to_xfer -= bytes_to_read; bytes_to_xfer -= bytes_to_read;
} }

View File

@ -787,7 +787,8 @@ int ADDCALL hackrf_set_sample_rate(hackrf_device* device, const double freq)
union { union {
uint64_t u64; uint64_t u64;
double d; double d;
} v = { .d = freq }; } v;
v.d = freq;
e = (v.u64 >> 52) - 1023; e = (v.u64 >> 52) - 1023;