Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - kingston

Pages: [1]
1
NXPTM M522XX, KINETIS and i.MX RT / K64 SPI Slave example
« on: July 03, 2018, 01:26:41 PM »
Hi all,

has anyone already used the K64 as a SPI slave?
I'm trying to talk to an ESP8266 as a SPI-wifi bridge but can't get the SPI on the K64 to work in slave mode.

So far I have set the module to slave mode like this:
SPI0_MCR = (SPI_MCR_SLAVE | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF);

and have configured the CS line as an input with a ISR when the edge is falling.

In my ISR I check for SPI0_SR & SPI_SR_RFDF to see if there is data available but there never is.

Also when I put data into SPI0_PUSHR_SLAVE I never see a change in the SDO line on my logic analyzer.

I know there are some CMSIS examples for a DSPI Slave on K64 and it is also mentioned in the reference manual but I couldn't get it to work.

Any help would be appreciated.

Thanks

Paul

2
µTasker general / GZIP compression support for webserver
« on: July 01, 2015, 12:18:49 PM »
Hello,

i am currently working on a project which has very limited storage in the SPI-flash but still needs a "fancy" website with a lot of javascript.
As javascript libraries are often over hundred kilobytes in size they waste space needed for other things.

I remembered reading about gzip compression for webservers but always thought the server would need to compress the files before sending them to the client.
After stumbling across another article it became clear to me that this is not the case and the only thing needed is an entry in the HTTP-header to inform the client that the data is compressed.

With this in mind I modified the HTTP-stack to fill in the needed information:

Code: [Select]
#if defined SUPPORT_GZIP_SERVING
static unsigned short fnAddContentTypeGZIP(CHAR *ptrBuffer, const CHAR *ptrType)
{
    CHAR *ptrContent = ptrBuffer;
    ptrContent = uStrcpy(ptrContent, "Content-Type: ");
    ptrContent = uStrcpy(ptrContent, ptrType);
    ptrContent = uStrcpy(ptrContent, "\r\n");
    ptrContent = uStrcpy(ptrContent, "Content-Encoding: gzip\r\n\r\n");

    return ((ptrContent - (CHAR *)ptrBuffer) - 2);
}
#endif

static unsigned short fnAddMimeContent(unsigned char *ptrBuffer, unsigned char ucMimeType)
{
    switch (ucMimeType) {
    #if defined MIME_TXT
    case MIME_TXT:
        return (fnAddContentType((CHAR *)ptrBuffer, "text/plain"));
    #endif
    #if defined MIME_CSS
    case MIME_CSS:
        return (fnAddContentType((CHAR *)ptrBuffer, "text/css"));
    #endif
    #if defined MIME_JAVA_SCRIPT
    case MIME_JAVA_SCRIPT:
        return (fnAddContentType((CHAR *)ptrBuffer, "application/javascript"));
    #endif
    #if defined MIME_PNG
    case MIME_PNG:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/png"));
    #endif
    #if defined MIME_JPG
    case MIME_JPG:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/jpg"));
    #endif
    #if defined MIME_BMP
    case MIME_BMP:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/bmp"));
    #endif
    #if defined MIME_GIF
    case MIME_GIF:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/gif"));
    #endif
#if defined SUPPORT_GZIP_SERVING
    case MIME_JAVA_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "application/javascript"));
        break;
    case MIME_CSS_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "text/css"));
        break;
    case MIME_HTML_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "text/html"));
        break;
#endif
    default:
        return 0;
    }
}
#endif

The function fnAddContentTypeGZIP adds the mime-type and an additional string "Content-Encoding: gzip" to the HTTP-header.

The new defines e.g. MIME_JAVA_GZIP have to be defined at the end of config.h for this to work. I added custom file extensions like jgz for compressed java and cgz for compressed css:

Code: [Select]
#if defined OPSYS_CONFIG                                                 // this is only set in the hardware module
    #if defined ETH_INTERFACE                                            // if we support Ethernet we define some constants for its (TCP/IP) use
        const unsigned char cucNullMACIP[MAC_LENGTH] = { 0, 0, 0, 0, 0, 0 };
        const unsigned char cucBroadcast[MAC_LENGTH] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; // used also for broadcast IP
    #endif

    #if defined SUPPORT_MIME_IDENTIFIER
    const CHAR *cMimeTable[] = {                                         // keep the ordering in the table to match the MIME type defines below!!
        (const CHAR *)"HTM",                                             // HTML file - will be interpreted by web server
        (const CHAR *)"JPG",                                             // JPG image
        (const CHAR *)"GIF",                                             // GIF image
        (const CHAR *)"CSS",                                             // CSS Cascading Style Sheets
        (const CHAR *)"JS",                                              // Java script
        (const CHAR *)"BIN",                                             // binary data file
        (const CHAR *)"TXT",                                             // text data file
(const CHAR *)"ICO",                                             // icon
        (const CHAR *)"BMP",                                             // BMP image
#ifdef  SUPPORT_GZIP_SERVING
(const CHAR *)"JGZ",                                             // gzipped javascript
(const CHAR *)"CGZ",                                             // gzipped css
(const CHAR *)"HGZ",                                             // gzipped html
#endif
        (const CHAR *)"???",                                             // all other types will be displayed as unknown
    };
    #endif
#endif

// File type identifiers
//
#define MIME_HTML                  0                                     // this and any lower types will be parsed by the web server
#define MIME_JPG                   1
#define MIME_GIF                   2
#define MIME_CSS                   3
#define MIME_JAVA_SCRIPT           4
#define MIME_BINARY                5
#define MIME_TXT                   6
#define MIME_ICON                  7
#define MIME_BMP                   8
#ifdef SUPPORT_GZIP_SERVING
#define MIME_JAVA_GZIP    9
#define MIME_CSS_GZIP    10
#define MIME_HTML_GZIP    11
#define UNKNOWN_MIME               12                                     // this entry is needed to terminate the list
#else
#define UNKNOWN_MIME               9                                     // this entry is needed to terminate the list
#endif

The new mime types get set when you write a file with one of the extensions to your storage.

I was able to get the filesize down to a fifth of the original so this really speeds up things. (179k -> 31k)

The only caveat I could find is that the original insert mechanisms with the pound-sign will not work when using a compressed HTML-file but as I am not using them anymore it doesn't really matter to me.

Maybe this will help others too when dealing with limited storage.

Kind Regards

Paul




3
Hey Mark,

we had some problem with our network activity led and the KSZ8081 PHY. The LINK_UP was detected just fine but LINK_DOWN was never received.
In the function fnCheckEthLinkState(void) in kinetis.c you mask the register value with PHY_LINK_STATE_CHANGE which is defined as:
Code: [Select]
#define PHY_LINK_STATE_CHANGE  (PHY_LINK_UP_INT | PHY_LINK_DOWN_INT)when using the KSZ8081.
This breaks the following else case:
Code: [Select]
else if (PHY_LINK_DOWN_INT & usInterrupt) {        // {27} add else so that the LINK UP event is not overwritten to UNKNOWNIf the define is changed to
Code: [Select]
#define PHY_LINK_STATE_CHANGE PHY_LINK_UP_INTthe LINK_DOWN event is detected.
   
Regards

Paul

4
Hey all,

I currently have to program a test for the rs-485 interface on our hardware but can't get it to work properly.
After reading the Kinetis Demo document it looks like my hardware should support automatic switching between RX and TX but I can't get it to work...
In my current configuration I can only receive characters but it will never send.


The initialisation code is as follows:
Code: [Select]
extern QUEUE_HANDLE fnSetNewSerialMode485(unsigned char ucDriverMode) {
TTYTABLE tInterfaceParameters; // table for passing information to driver
tInterfaceParameters.Channel = 2; // set UART channel for serial use
tInterfaceParameters.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE; // output buffer size
tInterfaceParameters.Task_to_wake = OWN_TASK; // wake self when messages have been received
tInterfaceParameters.Config = (CHAR_MODE | CHAR_8 | ECHO_RX_CHARS | SET_RS485_MODE | SET_RS485_NEG | NO_PARITY | ONE_STOP | NO_HANDSHAKE );

if ((SerialPort485ID = fnOpen(TYPE_TTY, FOR_I_O, &tInterfaceParameters))
!= 0) { // open or change the channel with defined configurations (initially inactive)
fnDriver(SerialPort485ID, (TX_ON | RX_ON ), 0); // enable rx and tx

}
return SerialPort485ID;
}

On receive my Tasks wakes up prints the received characters and should send a "Hello" with following function:
Code: [Select]
QUEUE_TRANSFER fnSend485Msg(unsigned char * cToSend) {
return (fnPrint((unsigned char *) cToSend, SerialPort485ID)); // send to UART2
}

I never receive the "Hello" on the pc-side. With another configuration (which i lost after playing around too much...) I received the "Hello" on the pc-side but couldn't receive on the K60. For me it looks like the control-lines aren't switching like they should but I even tried the example with manual switching of the lines and it doesn't work either.
Maybe someone has an idea what I'm doing wrong?

5
µTasker general / Time Server
« on: July 06, 2012, 12:31:21 PM »
Hey all,

I recently tried using the time servers in my project but it looks like it never tries to get the time.
What are the necessary steps to fetch the time?
Is defining USE_TIME_SERVERS not enough?
I can't find documentation about this other than some forum posts so please help me.

Thank You

Paul

6
µTasker general / uTasker Webserver
« on: June 14, 2012, 01:14:20 PM »
Hello,

I have a strange problem with the uTasker webserver. I'm using a Kinetis K60 and have put my website "index.htm" in "dir1" on the sd-card.
When I try to open the website by typing in the ip it serves the html source code.
When I explicitly call 192.168.2.7/index.htm it works and the website gets displayed.
Has anybody experienced this and maybe knows a fix?

Thanks

Paul

Pages: [1]