-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Start a new project via `make project` * Fix minor error cleaning rules * Add missing 'user_rf_cal_sector_set()' * Update user_main.c Use recommended setup for cal flash map. * Add sdk, 'make gitproject', inprove 'make project' Squashed commit of the following: commit 39574c3 Author: con-f-use <con-f-use@gmx.net> Date: Fri Mar 3 14:37:31 2017 +0100 Add recursive pulling to README commit fe86201 Author: con-f-use <con-f-use@gmx.net> Date: Fri Mar 3 14:33:21 2017 +0100 Small cleanups commit a77ffd9 Author: con-f-use <con-f-use@gmx.net> Date: Fri Mar 3 13:40:41 2017 +0100 Fix them separators Makefiles... commit 50c1085 Author: con-f-use <con-f-use@gmx.net> Date: Fri Mar 3 13:25:31 2017 +0100 Do not require Bash shell commit 96f5c52 Author: con-f-use <con-f-use@gmx.net> Date: Thu Mar 2 12:44:01 2017 +0100 Add 'make gitproject' and reflect changes in readme Needs to be tested! Also added the sdk as a submodule. Still need to change paths in the makefiles and test it. DO NOT USE THIS COMMIT * readme: typos * Minor updates to the readme Documentation of the commands in `./fwsrc/commonservies.c` still to come * Document commands in `./commonsercies.c` * Fix typo in README.md
- Loading branch information
Showing
11 changed files
with
454 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "toolchain/esp_nonos_sdk"] | ||
path = toolchain/esp_nonos_sdk | ||
url = https://github.com/cnlohr/esp_nonos_sdk.git |
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
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,28 @@ | ||
//Copyright 2015 <>< Charles Lohr, see LICENSE file. | ||
|
||
#include <commonservices.h> | ||
#include "esp82xxutil.h" | ||
|
||
int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, unsigned short len) { | ||
char * buffend = buffer; | ||
|
||
switch( pusrdata[1] ) { | ||
// Custom command test | ||
case 'C': case 'c': | ||
buffend += ets_sprintf( buffend, "CC" ); | ||
printf("CC"); | ||
return buffend-buffer; | ||
break; | ||
|
||
// Echo to UART | ||
case 'E': case 'e': | ||
if( retsize <= len ) return -1; | ||
ets_memcpy( buffend, &(pusrdata[2]), len-2 ); | ||
buffend[len-2] = '\0'; | ||
printf( "%s\n", buffend ); | ||
return len-2; | ||
break; | ||
} | ||
|
||
return -1; | ||
} |
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,165 @@ | ||
//Copyright 2015 <>< Charles Lohr, see LICENSE file. | ||
|
||
#include "mem.h" | ||
#include "c_types.h" | ||
#include "user_interface.h" | ||
#include "ets_sys.h" | ||
#include "uart.h" | ||
#include "osapi.h" | ||
#include "espconn.h" | ||
#include "esp82xxutil.h" | ||
#include "commonservices.h" | ||
#include "vars.h" | ||
#include <mdns.h> | ||
|
||
#define procTaskPrio 0 | ||
#define procTaskQueueLen 1 | ||
|
||
static volatile os_timer_t some_timer; | ||
static struct espconn *pUdpServer; | ||
usr_conf_t * UsrCfg = (usr_conf_t*)(SETTINGS.UserData); | ||
|
||
//int ICACHE_FLASH_ATTR StartMDNS(); | ||
|
||
|
||
void user_rf_pre_init(void) { /*nothing*/ } | ||
|
||
|
||
|
||
char * strcat( char * dest, char * src ) | ||
{ | ||
return strcat(dest, src ); | ||
} | ||
|
||
|
||
|
||
//Tasks that happen all the time. | ||
|
||
os_event_t procTaskQueue[procTaskQueueLen]; | ||
|
||
static void ICACHE_FLASH_ATTR procTask(os_event_t *events) | ||
{ | ||
CSTick( 0 ); | ||
system_os_post(procTaskPrio, 0, 0 ); | ||
} | ||
|
||
//Timer event. | ||
static void ICACHE_FLASH_ATTR myTimer(void *arg) | ||
{ | ||
CSTick( 1 ); // Send a one to uart | ||
} | ||
|
||
|
||
//Called when new packet comes in. | ||
static void ICACHE_FLASH_ATTR | ||
udpserver_recv(void *arg, char *pusrdata, unsigned short len) | ||
{ | ||
struct espconn *pespconn = (struct espconn *)arg; | ||
|
||
uart0_sendStr("X"); | ||
} | ||
|
||
void ICACHE_FLASH_ATTR charrx( uint8_t c ) | ||
{ | ||
//Called from UART. | ||
} | ||
|
||
void user_init(void) | ||
{ | ||
uart_init(BIT_RATE_115200, BIT_RATE_115200); | ||
|
||
uart0_sendStr("\r\nesp82XX Web-GUI\r\n" VERSSTR "\b"); | ||
|
||
//Uncomment this to force a system restore. | ||
// system_restore(); | ||
|
||
CSSettingsLoad( 0 ); | ||
CSPreInit(); | ||
|
||
pUdpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); | ||
ets_memset( pUdpServer, 0, sizeof( struct espconn ) ); | ||
espconn_create( pUdpServer ); | ||
pUdpServer->type = ESPCONN_UDP; | ||
pUdpServer->proto.udp = (esp_udp *)os_zalloc(sizeof(esp_udp)); | ||
pUdpServer->proto.udp->local_port = COM_PORT; | ||
espconn_regist_recvcb(pUdpServer, udpserver_recv); | ||
|
||
if( espconn_create( pUdpServer ) ) | ||
{ | ||
while(1) { uart0_sendStr( "\r\nFAULT\r\n" ); } | ||
} | ||
|
||
CSInit(); | ||
|
||
//Set GPIO16 for INput | ||
WRITE_PERI_REG(PAD_XPD_DCDC_CONF, | ||
(READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection | ||
|
||
WRITE_PERI_REG(RTC_GPIO_CONF, | ||
(READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable | ||
|
||
WRITE_PERI_REG(RTC_GPIO_ENABLE, | ||
READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); //out disable | ||
|
||
SetServiceName( "espcom" ); | ||
AddMDNSName( "esp82xx" ); | ||
AddMDNSName( "espcom" ); | ||
AddMDNSService( "_http._tcp", "An ESP82XX Webserver", WEB_PORT ); | ||
AddMDNSService( "_espcom._udp", "ESP82XX Comunication", COM_PORT ); | ||
AddMDNSService( "_esp82xx._udp", "ESP82XX Backend", BACKEND_PORT ); | ||
|
||
//Add a process | ||
system_os_task(procTask, procTaskPrio, procTaskQueue, procTaskQueueLen); | ||
|
||
//Timer example | ||
os_timer_disarm(&some_timer); | ||
os_timer_setfn(&some_timer, (os_timer_func_t *)myTimer, NULL); | ||
os_timer_arm(&some_timer, 100, 1); | ||
|
||
printf( "Boot Ok.\n" ); | ||
|
||
wifi_set_sleep_type(LIGHT_SLEEP_T); | ||
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); | ||
|
||
system_os_post(procTaskPrio, 0, 0 ); | ||
} | ||
|
||
|
||
//There is no code in this project that will cause reboots if interrupts are disabled. | ||
void EnterCritical() { } | ||
|
||
void ExitCritical() { } | ||
|
||
|
||
//For SDK 2.0.0 only. | ||
uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void) | ||
{ | ||
enum flash_size_map size_map = system_get_flash_size_map(); | ||
uint32 rf_cal_sec = 0; | ||
|
||
switch (size_map) { | ||
case FLASH_SIZE_4M_MAP_256_256: | ||
rf_cal_sec = 128 - 8; | ||
break; | ||
|
||
case FLASH_SIZE_8M_MAP_512_512: | ||
rf_cal_sec = 256 - 5; | ||
break; | ||
|
||
case FLASH_SIZE_16M_MAP_512_512: | ||
case FLASH_SIZE_16M_MAP_1024_1024: | ||
rf_cal_sec = 512 - 5; | ||
break; | ||
|
||
case FLASH_SIZE_32M_MAP_512_512: | ||
case FLASH_SIZE_32M_MAP_1024_1024: | ||
rf_cal_sec = 1024 - 5; | ||
break; | ||
|
||
default: | ||
rf_cal_sec = 0; | ||
break; | ||
} | ||
|
||
return rf_cal_sec; | ||
} |
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,19 @@ | ||
|
||
#ifndef _VARS_H | ||
#define _VARS_H | ||
|
||
#include "commonservices.h" | ||
|
||
#define BUILD_BUG_ON(condition) extern int build_bug_on[!(condition)-1] | ||
|
||
typedef struct { | ||
uint8_t ptrn; ///< Pattern to display on connected leds | ||
uint16_t nled; ///< Number of connected LEDs | ||
uint8_t clr[3]; ///< Color data (used for PATTERN_CONST) | ||
// ... add more here ... | ||
} __attribute__((__packed__)) usr_conf_t; | ||
BUILD_BUG_ON(sizeof(usr_conf_t)>USERDATA_SIZE); // Produce invalid code if struct is too large ("best" way of size checking at compile time) | ||
|
||
extern usr_conf_t * UsrCfg; ///< User data preserved between esp boots | ||
|
||
#endif |
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
Submodule esp_nonos_sdk
added at
7d66ff
File renamed without changes.
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
aa8ba2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@con-f-use Considering you're pulling in my copy of the sdk, do we really want the default to be ~/esp8266/esp-open-sdk?
aa8ba2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... I don't know where that line came from all of a sudden.
None the less, it says
SDK ?= $(PWD)/esp82xx/toolchain/esp_nonos_sdk
incommon.mf
so it will default to using your version of the sdk.aa8ba2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know what the best approach would be here :-/ I think removing the reference to ~/ from esp82xx is probably the right move.