Author Topic: GET_SDCARD_WP_STATE() no prototype  (Read 3816 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 433
    • View Profile
GET_SDCARD_WP_STATE() no prototype
« on: November 14, 2014, 05:55:01 PM »
Hi Mark,
  I have loaded the latest uFAT, and during compiling I get no prototype for  GET_SDCARD_WP_STATE(), what should this be?  I am not using write protect, so do I just do a #define GET_SDCARD_WP_STATE() 0?

Regards
Neil
« Last Edit: November 14, 2014, 05:56:52 PM by neil »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: GET_SDCARD_WP_STATE() no prototype
« Reply #1 on: November 14, 2014, 06:06:06 PM »
Hi Neil

This is not a new but was added quite some time ago to read in the write protect input from the SD card socket, if available.
If you set
#define GET_SDCARD_WP_STATE() 0
it will disable the check and can be used for HW without a switch, or when the WP state is not of interest. In this case writes to the card will always be possible.

An example of use to read the real WP switch setting is:
#define GET_SDCARD_WP_STATE() (_READ_PORT_MASK(E, WRITE_PROTECT_INPUT))
which assumes that the port pin is on port E, eg.
#define WRITE_PROTECT_INPUT     PORTE_BIT27

Somewhere the input will be configured, eg. as a part of the POWER_UP_SD_CARD() macro
_CONFIG_PORT_INPUT(E, (WRITE_PROTECT_INPUT | SD_CARD_DETECTION), (PORT_PS_UP_ENABLE));
Here it is is done together with the configuration of the SD_CARD_DETECTION switch (when available).

There are various examples for a number of eval. boards in app_hw_kinetis.h in V1.4.7.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 433
    • View Profile
Re: GET_SDCARD_WP_STATE() no prototype
« Reply #2 on: November 14, 2014, 06:11:46 PM »
Thanks Mark

Regards
Neil