-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #25: Implement automatic support for CF20/CF21 using the same bin
- Loading branch information
Showing
10 changed files
with
174 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
|
||
#define PLATFORM_DEVICE_TYPE_STRING_MAX_LEN 33 | ||
#define PLATFORM_DEVICE_TYPE_MAX_LEN 31 | ||
|
||
/** | ||
* Fetch deviceType string from flash | ||
* | ||
* This function defaults to "0;CF20;R=D" if no string is present in the | ||
* hardware | ||
* | ||
* \param [out] deviceTypeString Buffer of at least | ||
* PLATFORM_DEVICE_TYPE_STRING_MAX_LEN bytes | ||
* where the platform string will be stored | ||
*/ | ||
void platformGetDeviceTypeString(char *deviceTypeString); | ||
|
||
/** | ||
* Parse deviceType string to extract the deviceType | ||
* | ||
* Ignores the key=value sections. | ||
* | ||
* \param [in] deviceTypeString deviceTypeString extracted from the hardware | ||
* \param [out] deviceType Buffer of at least PLATFORM_DEVICE_TYPE_MAX_LEN | ||
* bytes where the device type will be stored | ||
* \return 0 in case of success, 1 in case of failure. | ||
*/ | ||
int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType); | ||
|
||
/** | ||
* Initialize the platform | ||
* | ||
* Initialize the platform discovering capabilities and returns if it has been successful | ||
* | ||
* \return 0 in case of success, 1 in case of failure. | ||
*/ | ||
int platformInit(); | ||
|
||
// ************** Capabilities functions ************** | ||
// The following functions can be implemented by different platform to give | ||
// access to the current device capabilities. Not all platform has to implement | ||
// all functions | ||
bool platformHasRfx2411n(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "platform.h" | ||
|
||
#include <string.h> | ||
|
||
static const char *defaultDeviceType = "0;CF20;R=D"; | ||
|
||
static volatile unsigned char *deviceTypeStringLocation = 0x3FFE0; | ||
|
||
void platformGetDeviceTypeString(char *deviceTypeString) | ||
{ | ||
if (deviceTypeStringLocation[0] == 0xffu) { | ||
strncpy(deviceTypeString, defaultDeviceType, 32); | ||
deviceTypeString[32] = 0; | ||
} else { | ||
strncpy(deviceTypeString, deviceTypeStringLocation, 32); | ||
deviceTypeString[32] = 0; | ||
} | ||
} | ||
|
||
int platformParseDeviceTypeString(const char* deviceTypeString, char* deviceType) { | ||
char *state; | ||
char *tok; | ||
|
||
// first token is the version, must be "0" | ||
tok = strtok_r(deviceTypeString, ";", &state); | ||
if (tok == NULL || strcmp(tok, "0")) { | ||
return 1; | ||
} | ||
|
||
// Second token is the platform name | ||
tok = strtok_r(NULL, ";", &state); | ||
if (tok == NULL) { | ||
return 1; | ||
} | ||
strncpy(deviceType, tok, PLATFORM_DEVICE_TYPE_MAX_LEN); | ||
deviceType[PLATFORM_DEVICE_TYPE_MAX_LEN-1] = '\0'; | ||
|
||
// Next tokens are KEY=VALUE pairs, ignored for now | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "platform.h" | ||
|
||
#include <string.h> | ||
|
||
bool has_rfx2411n = false; | ||
|
||
bool platformHasRfx2411n() | ||
{ | ||
return has_rfx2411n; | ||
} | ||
|
||
int platformInit() | ||
{ | ||
static char deviceTypeString[PLATFORM_DEVICE_TYPE_STRING_MAX_LEN]; | ||
static char deviceType[PLATFORM_DEVICE_TYPE_MAX_LEN]; | ||
|
||
platformGetDeviceTypeString(deviceTypeString); | ||
if (platformParseDeviceTypeString(deviceTypeString, deviceType) != 0) { | ||
return 1; | ||
} | ||
|
||
if (!strcmp(deviceType, "CF20")) { | ||
has_rfx2411n = false; | ||
} else if (!strcmp(deviceType, "CF21")) { | ||
has_rfx2411n = true; | ||
} else { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "platform.h" | ||
|
||
int platformInit() | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.